CSLA’s notion of Edit Level and Infragistics Ultra WinGrid

CSLA’s notion of Edit Level and Infragistics Ultra WinGrid

Old forum URL: forums.lhotka.net/forums/t/10339.aspx


Lazaro posted on Wednesday, May 04, 2011

We are having an issue with CSLA’s notion of Edit Level and Infragistics Ultra WinGrid.

When we bind (through a binding source) a Business Collection (with items that have other collections) to a WinGrid, all the child and grandchild collections get also bound in inner bands (whether we want to show them or not). As soon as it gets bound, Infragistics WinGrid automatically activates the first row of the first band (calling IEditableObject.BeginEdit() on the row’s object), as well as the first row of every child band of such activated row, and so on (every time a row gets activated the first row of all its child bands also get activated). For instance if we had three bands (Parent-Child-Grandchild) like the sample below, Infragistics will call BeginEdit() to rows 1, 1.1, and 1.1.1 as soon as the grid gets bound, and, therefore, the three objects in such rows get BeginEdit() called.

1.       A

1.1.    A

1.1.1. A

1.1.2. B

1.2.    B

1.2.1. A

1.2.2. B

1.3.    C

1.3.1. A

1.3.2. B

2.       B

2.1.    A

2.1.1. A

2.1.2. B

2.2.    B

2.3.    C

When the EndEdit() gets called on the object in the first row of the first band (one case is when the user selects another row), Infragistics DO NOT call the EndEdit() on the object in the first row of the inner bands for which it previously called BeginEdit() [in the example above row 1.1 and 1.1.1]. Therefore, the child and grandchild objects in inner bands will have Edit Level greater than 0 when they should have been 0. That behavior is creating us problems because it generates an Edit Level mismatch.

Can anyone point us in the right direction, or tell us any work around that you did to result the issue?

Your help will be greatly appreciated.

Lazaro Falcon

PS: We are using CSLA version 4.1.0 and Infragistics version 10.3

simpleman replied on Tuesday, May 10, 2011

Hi Lazaro,

We've had the same problem with CSLA 3.6 and Infragisitcs version 10.3

I first tried it with Infragisitcs  version 9.2 to check if that was the issue but it wasn't.  

I found a solution by creating a BindingSource for each band and pointing each BindingSource to its parent.

For example:

Grid.DataSource = BindingSource1

BindingSource1.DataSouce = BusinessClass

for band 1

for band 2

etc etc.
Hope this helps,
Nathan.

Lazaro replied on Tuesday, May 10, 2011

Hi Nathan,

Thank you very much for your help, I would like to tell you what I did to confirm that my approach is similar to what you did. In my case I have a child collection and every child has its own collection of children (grandchildren of the root object). I, as you suggested, created two binding sources (one for the children collection (Band 1) and another for the grandchildren collection (Band 2)) and as you can see in the following event I unbind the grandchild collection and rebind it again. This is working for me, but I would like to confirm with you because maybe you have a better solution implemented.

    private void workUnitsBindingSource_CurrentChanged(object sender, EventArgs e)
    {
      grandChildBindingSource.UnbindDataSource(truefalse);
      LNRCWUTest lnrCWUTest = ((BindingSource)sender).Current as LNRCWUTest;
      grandChildBindingSource.BindDataSource(lnrCWUTest.LNRTestsObj);

         }

PS: The UnbindDataSource and BindDataSource are some of the common helper binding methods.

simpleman replied on Thursday, May 12, 2011

Hi Lazaro,

What you're describing in class structure sounds similar to the structure I'm using.  I have an editableRoot with an editable child list, and each of the items within that child list also contains a editable child  list.

My editable root is bound to various text boxes etc and the child collection is bound to the grid to give the multiple bands. I have a binding source for my editable root and then a binding source for each band.  So band(1) binding source is fed from the binding source of band(0) and band(0)'s binding source is fed from the editable root binding source.  I didn't have to add any additional code to as per your example as it all seems to work.

When I tested it my properties were edited by typing data direct into a cell and it was all fine.  However this isn't how the data was going to be editing in the final solution, and the final solution gave me the same error again.

My child collection data is a list of word and excel files and the contents need to be managed via button clicks not by typing in text.  Each of the bands was effectively read only in terms of editing the contents of a cell because I was using a button on each cell to select a file.  Selection of the file would then populate properties in that class that are both hidden and displayed columns.  Changing any of the properties via code was causing an edit level mismatch.  I needed to ApplyEdit after I changed the properties via code to resolve that problem.  

I am one for, if you've found a solution that works go with it.

Nathan

jmcphers replied on Monday, April 02, 2012

Does anyone have a good solution to this issue?  "Lazaro" has clearly stated the issue that I am experiencing regarding binding child and grandchild objects to the Infragistics Ultragrid.  I have followed the recommendations regarding setting up the binding source by Simpleman:

 

I found a solution by creating a BindingSource for each band and pointing each BindingSource to its parent.

For example:

Grid.DataSource = BindingSource1

BindingSource1.DataSouce = BusinessClass

for band 1

for band 2

However I still receive edit mismatch errors on update and when applying an undo.  I was not able to use the additioanl information regarding the UnbindDataSource methods as they appear to not be available (I am using CSLA 3.8 and not 4.1)

    private void workUnitsBindingSource_CurrentChanged(object sender, EventArgs e)
    {
      grandChildBindingSource.UnbindDataSource(truefalse);
      LNRCWUTest lnrCWUTest = ((BindingSource)sender).Current as LNRCWUTest;
      grandChildBindingSource.BindDataSource(lnrCWUTest.LNRTestsObj);

         }

PS: The UnbindDataSource and BindDataSource are some of the common helper binding methods.

Any help on this would be much appreciated as this is a critical for me.

Thanks in advance

Joe

 

Copyright (c) Marimer LLC