We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Collapsing of groups

Thread ID:





29751 Jun 2,2005 12:35 PM UTC Jun 2,2005 03:36 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On June 2, 2005 12:35 PM UTC

I have a data table shown in a grouping grid and refresh the table using dataTable.Clear() dataAdapter.Fill(dataTable) After I have done this, all the groups of the grid are collapsed. If I omit dataTable.Clear() 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.)

Administrator [Syncfusion]
Replied On June 2, 2005 01:36 PM UTC

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. 

Administrator [Syncfusion]
Replied On June 2, 2005 03:36 PM UTC

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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon