Hi All,
I have an issue with a child list that I would like to discuss.
I am using CSLA 3.5.
I have a BusinessBase descendant called customer which has a list (a descendent of BusinessListBase) of BusinessBase decedents called orders. I have bound the list of orders to a grid and allowed new rows to be added.
When a user clicks on the ‘new row’ of the order grid a new order row is created. If the user then clicks away from the new row or presses the Esc key before editing the new row I want the creation of the new order to be cancelled as per the normal grid behaviour when using a data set.
I find that if I declare the order list property using the method from ProjectTracker (i.e. using FieldManager and the LoadProperty method) I do not get this behaviour. I find if I do one of the following I do get this behaviour:
1 Use a private backing field and not the field manager and initialise the field in code.
2 Override the OnPropertyChanged method on the customer so that I can avoid invoking the _nonSerializableChangedHandlers
Both of these have side effects that have to be addressed.
Can anyone tell me if one of the above is a good approach, and if not, then what is?
Regards,
Patrick
Thanks for your reply Rocky, but I still seem to get the problem.
I have replicated the problem in PTWin (V3.5.1) by adding a new form and dragging the project data source and then the project resources from the data source window onto it. I have put a line in the constructor to create a project instance using the GetProject method of the project class using a hard coded guid. This project is assigned to the data source of the project binding source. To get the grid to work I have added a simple AddNewCore method to ProjectResources that adds a new project resource using a hard coded resource id.
I can get the grid to cancel newly added resources by overriding OnPropertyChanged in Project with an empty method which suggests it might be something to do with what this method does in BusinessBase, but of course this has unacceptable side effects.
I have got the grid view working in my current project by not using the FieldManager but would prefer to use the recommended technique if this can be done.
Thanks again for you help,
Regards,
Patrick
Thanks for checking. The best thing you can do to help is to
replicate the problem in the test project specifically targeted at Windows
Forms data binding issues:
svn://svn.lhotka.net/csla/samples/trunk/RootChildGrandchildWinFormTest
You’ll need TortoiseSvn to download the code, but if you
can get the issue to occur in that sample, and can then send me the repro
steps, that’d be incredibly helpful!
Rocky
From: FatPigeon
[mailto:cslanet@lhotka.net]
Sent: Thursday, June 12, 2008 11:17 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] New Child Row Cancellation
Thanks for your reply Rocky, but I
still seem to get the problem.
I have replicated the problem in
PTWin (V3.5.1) by adding a new form and dragging the project data source and
then the project resources from the data source window onto it. I have put a
line in the constructor to create a project instance using the GetProject
method of the project class using a hard coded guid. This project is assigned
to the data source of the project binding source. To get the grid to work I
have added a simple AddNewCore method to ProjectResources that adds a new
project resource using a hard coded resource id.
I can get the grid to cancel newly
added resources by overriding OnPropertyChanged in Project with an empty method
which suggests it might be something to do with what this method does in
BusinessBase, but of course this has unacceptable side effects.
I have got the grid view working in
my current project by not using the FieldManager but would prefer to use the
recommended technique if this can be done.
Thanks again for you help,
Regards,
Patrick
Hi Rocky,
I have had a look at the RootChildGrandChildWinFormTest project and have found that it already illustrates the problem as is. To see what I mean:
1 Run the application
2 Click on the new row of the child grid and you get a new row with id 5.
3 Click on the row for id 4 and the new row stays:
Or
1 Run the application
2 Click on the new row and you get a new row with id 5.
3 Press Esc and the new row stays.
If you override the OnPropertyChanged with an empty method the new row will go at step 3. You have to edit the new row to confirm that you actually meant to create a new row and it was not just an accidental click.
There is a related problem with undo:
1 Run the application
2 Click on a new row to get the new child with id 5.
3 Put some text in the name cell
4 Click on the row with id 4 to trigger the end edit.
5 Click on the row with id 5 and edit the name.
6 Move to the id cell with id 5 by pressing shift tab or using the mouse making sure you do not move to another row.
7 Press esc – the row should undo and does once the above change has been made.
There are similar problems with the grandchild grid which can be overcome by overriding the OnPropertyChanged method of the child class with an empty method.
Sorry to be a pain,
Regards,
Patrick
I wonder what the correct rule/pattern is then.
Obviously disabling INotifyPropertyChanged by never raising a
PropertyChanged event isn’t the right answer – that’d have
negative side-effects all over the place.
So does the grid somehow expect that new rows won’t raise
the event, but all other rows will?
Rocky
I’ll be honest, I don’t have time to research it in
the near future. So your options are to have me put it on the wish list and
wait until I have time – perhaps this fall or winter – or to
research it yourself and see if you can figure out the answer – or to
live with the way the grid behaves now.
Rocky
From: FatPigeon
[mailto:cslanet@lhotka.net]
Sent: Tuesday, June 17, 2008 7:08 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: New Child Row Cancellation
I
agree, disabling INotifyPropertyChanged is not the right answer. I
mentioned that having an empty OnPropertyChanged method has an effect because I
thought this may be helpful in tracking down the problem. I did not mean to
suggest is was the answer.
Your
question about 'what the grid expects' is a good one - I wish I knew - do
you have any contacts at Microsoft that may help?.
However,
before continuing with this issue, do you think I should be expecting this 'new
row cancellation' behavior or should I just work with the way the
grid behaves in RootChildGrandchildWinFormTest?
Regards,
Patrick.
Thanks Rocky, I will try it out.
Rocky,
I have downloaded Csal 3.5.1 beta 2 (http://www.lhotka.net/cslanet/download.aspx) but it does not seem to have the ChildChanged stuff in it. Althought the change log mentions it.
Am I missing something?
Regards,
Patrick
The code change is only in the source - it is not in Beta 2. Should be in Beta 3 or the Released version.
Joe
Hi Joe,
And where is the source?
Patrick
Please note that the fix you want is in RTM release 0807xx –
the RTM is beyond Beta 2, and the ‘xx’ indicates that it isn’t
out yet – otherwise those digits would be the rest of the release date.
To get the ChildChanged stuff, you need to get the code directly
from subversion or wait until I do the RTM release.
Rocky
From: FatPigeon
[mailto:cslanet@lhotka.net]
Sent: Wednesday, July 23, 2008 7:09 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: RE: New Child Row Cancellation
Rocky,
I have downloaded Csal 3.5.1 beta 2 (http://www.lhotka.net/cslanet/download.aspx)
but it does not seem to have the ChildChanged stuff in it. Althought the change
log mentions it.
Am I missing something?
Regards,
Patrick
Rocky,
Thanks for the information.
I have tried to find the source code but am having no luck
I have used tortoise svn to navigate to :
svn://svn.lhotka.net/csla/tags/V3
but there is no entry 3.5.1. 3.5.0 is the latest.
I have tried to navigate to :
svn://svn.lhotka.net/cslacvs/viewcv.cgi/trunk/
but get an message:
Error * No repository found in 'svn://svn.lhotka.net/cslacvs/viewcv.cgi/trunk'
Any ideas?
Patrick
My ISP has been having some trouble the last 2-3 days. They say
they replaced a router, so hopefully that helps.
Rocky
From: tetranz
[mailto:cslanet@lhotka.net]
Sent: Wednesday, July 23, 2008 4:42 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: RE: RE: New Child Row Cancellation
When I tried getting the fix from svn a day or two ago I
ended up with a permissions error. Someone else reported the same thing a week
or so ago. My understanding of svn is very close to zero but I managed to
navigate around the web interface and get the two files checked in for that
fix.
This page is a master index into the web view and also provides
the URIs needed to use TortoiseSvn (or other subversion client) to directly
access the repository:
http://www.lhotka.net/cslanet/Repository.aspx
The latest 3.5.1 code is in the CSLA .NET dev tree (svn://svn.lhotka.net/csla/trunk
or http://www.lhotka.net/cslacvs/viewvc.cgi/trunk/)
Rocky
Rocky, Tetranz
Thanks for your help - found it now.
So far I have only tried it out on RootChildGrandChildWinFormTest but it seems to work fine.
Regards,
Patrick
Copyright (c) Marimer LLC