Offtopic: Infragistics Child Collection Binding After Undo

Offtopic: Infragistics Child Collection Binding After Undo

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


ChristianPena posted on Monday, December 11, 2006

Good morning,

I am facing what appears to be a binding issue with the Infragistics UltraWinGrid (Windows Forms). I have the grid bound to a RoleCollection, an Editable Root List. In the list are Role objects, Editable Child objects. Each Role object has an Editable Child list containing RoleRight objects. The list is lazy-loaded when the Role is expanded.

The error occurs when I delete a RoleRight and then undo the changes, i.e. CancelEdit on the entire RoleCollection. When the changes are cancelled, the object is restored, but the grid contains one less row than it should, though the binding is correct in that the deleted RoleRight object is shown if it wasn't the last item in the list.

So if I have 3 RoleRight objects in the list and delete the middle one, I now have 2 rows in the band showing the first and third RoleRight objects. If I undo, I have 3 RoleRight objects, but I only see two rows in the band showing the first and second RoleRight objects.

I am hoping someone has seen this type of error before as I cannot see any reason why the grid is not displaying the correct number of rows.

Christian

ChristianPena replied on Monday, December 11, 2006

After some investigation, I have some more clues but no answers.

Suppose I have the following RoleRights:

  1. CanReadNote
  2. CanWriteNote
  3. CanDeleteNote

If I delete CanWriteNote (2), then the grid displays, as expected:

  1. CanReadNote
  2. CanDeleteNote

If I undo, then the grid displays, incorrectly:

  1. CanReadNote
  2. CanWriteNote

The third item, CanDeleteNote is in the collection, but it is not displayed in the grid.

The other behavior that I observed is that if I add a new item to the collection and then undo it, and then delete the 2nd item and undo, I get the correct results. Why does adding a new item and undoing it cause the list to bind to the grid correctly?

Any thoughts or ideas are highly appreciated.

Christian

 

ChristianPena replied on Monday, December 11, 2006

Problem solved.

I had a "BindingSource.EndEdit()" in the Delete button handler. Once it was removed, the form functioned as expected.

The next question: Why does EndEdit prevent the undo in the UltraWinGrid?

Christian

ajj3085 replied on Tuesday, December 12, 2006

That I can help with.  EndEdit will cause your BOs to accept changes.  This basically throws out the state for the last undo operation.  Having the EndEdit in there was throwing off the undo stack somehow.

ChristianPena replied on Tuesday, December 12, 2006

I see.

The only thing that bothers me is that the deleted item was returned to the collection, so in that sense, the undo was correct. Only 2 of the 3 items were displayed, so it seems to point to a problem in some part of the binding process.

I will come back to it when time permits. Thanks for the response.

Christian

ajj3085 replied on Tuesday, December 12, 2006

Well you can have more than one state of undo.  The problem is likely that the objects were not at the same EditLevel, so things got wacky quickly.

ChristianPena replied on Tuesday, December 12, 2006

Thanks again. That sounds like the issue. I'll post here when I get to the bottom of it. Hopefully it will save others the trouble.

Christian

Copyright (c) Marimer LLC