I have a data table shown in a grouping grid and refresh the table using
After I have done this, all the groups of the grid are collapsed. If I omit
the groups are not collapsed, but then my data table will not reflect the changes correctly if any records are deleted from the data base. Is there any simple way I can fix this so that the grouping status of the grid does not change after the refresh operation? (Of cource if the structure of the table has changed completely the grouping status must also change.)
ADAdministrator Syncfusion Team June 2, 2005 08:36 AM
I think the reason you are seeing this behavior is that when all the records from a group are removed, that group is marked as collapsed and stays that way event if you add new records later.
One solution might be to add code that remembers the dataTable.Rows.Count before your call to adapter.Fill. Then afterwards have code like:
for(int i = 0; i < oldRowCount; ++i)
This would add all the new records first, and then remove the old ones later. (without calling DataTable.Clear). In this case, I think the expand state would remain as before. This does assume the DataTable schema does not change.
ADAdministrator Syncfusion Team June 2, 2005 10:36 AM
I believe a problem with this solution is that the adapter will replace instead of adding rows with the same primary key. Thus, one risk to delete rows that were just read.
Instead, I tried to loop through all groups and save the expanded/collapsed state. After reading the new data, I search for the same groups and set the expanded/collapsed state. This seems to work fine.