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. Image for the cookie policy date
close icon

Maintaining group expanded/collapsed states on refresh

Hi,

When I reinitilise the grouping grid or apply filters or sorting programmatically, I lose my group state (i.e. those that were collapsed become expanded by default).

How can I prevent this from happening or reapply the group states afterwards?

Thanks very much!


13 Replies

JO Johnson Syncfusion Team April 11, 2008 11:32 PM UTC

Hi Mitul,

When you call the Reinitialize method in a GroupingGrid control, It automatically collapse group state. But You can persist the group state for a single grouped column (no nested groups) at a time to iterate through the collection of groups and save a list of the ones that are expanded. Here is a little sample.

Sample:
http://websamples.syncfusion.com/Samples/Grid.Windows/F72845/main.htm


Please let me know if you need further assistance.

Best regards,
Johnson




MI mitul April 17, 2008 05:25 PM UTC

Thanks for this, very useful. I was able to extend the solution to work for all group levels.

Can you please let me know if there is a way to maintain the selected records when I call reinitialise?

I have tried to copy the collection in Catergorizing event and re apply in Categorized, but by the time Categorizing is fired, the collection is emptied. Is there any possible solution to this?

Thanks again,
Mitul

>Hi Mitul,

When you call the Reinitialize method in a GroupingGrid control, It automatically collapse group state. But You can persist the group state for a single grouped column (no nested groups) at a time to iterate through the collection of groups and save a list of the ones that are expanded. Here is a little sample.

Sample:
http://websamples.syncfusion.com/Samples/Grid.Windows/F72845/main.htm


Please let me know if you need further assistance.

Best regards,
Johnson






JO Johnson Syncfusion Team April 19, 2008 12:29 AM UTC

Hi Mitul,

Thank you for your update.

To maintain Selected records after reinitialize of the Grid , you need to collect all Row Index’s of selected records and programmatically select all those records by explicitly use of below code snippet.

foreach (SelectedRecord Rec in this.gridGroupingControl1.Table.SelectedRecords)
{
if (Rec.Record.Kind == DisplayElementKind.Record)
{
Record record = Rec.Record;
objPersistSelectRecords.Add( record) ;
}
}
this.gridGroupingControl1.Reinitialize();

for (int j = 0; j < objPersistSelectRecords.Count; j++)
{
Record record = objPersistSelectRecords[j] as Record;
int RowIndex = this.gridGroupingControl1.Table.NestedElements.IndexOf( record );
Record OriginalRecord = this.gridGroupingControl1.Table.NestedElements[RowIndex].GetRecord();
if (OriginalRecord.Kind == DisplayElementKind.Record)
{
if (OriginalRecord.ParentGroup != null)
OriginalRecord.ParentGroup.IsExpanded = true;

OriginalRecord.SetSelected(true);
}
}
Please refer the sample for implementation.

Sample:

http://websamples.syncfusion.com/Samples/Grid.Windows/F72845_N/main.htm


Please let me know if you need further assistance.

Best regards,
Johnson





PT Peter Trevor NO LONGER WITH COMPANY September 8, 2008 04:28 PM UTC

Hi

I'm having a similar problem but the example given doesn't work for me. In my case I'm 'refreshing' the grid by replacing the grid's datasource (a dataset) with a new one. This is causing the groups to collapse but doesn't seem to fire the ...TableDescriptor.GroupedColumns.Changing or ...TableDescriptor.GroupedColumns.Changed events. Since I already have an event in place that is causing the refresh in the first place I tried to rewrite the event handlers from the example but couldn't determine what to set the scd (SortColumnDescriptor) to be ... or why e.Action is checked.

Regards Pedro

>Hi Mitul,

When you call the Reinitialize method in a GroupingGrid control, It automatically collapse group state. But You can persist the group state for a single grouped column (no nested groups) at a time to iterate through the collection of groups and save a list of the ones that are expanded. Here is a little sample.

Sample:
http://websamples.syncfusion.com/Samples/Grid.Windows/F72845/main.htm


Please let me know if you need further assistance.

Best regards,
Johnson






PT Peter Trevor NO LONGER WITH COMPANY September 9, 2008 11:39 AM UTC

Never mind, I figured it out.





AD Administrator Syncfusion Team November 25, 2010 02:33 AM UTC

I am having the same issue. Please the following link http://websamples.syncfusion.com/Samples/Grid.Windows/F72845/main.htm is not working. Is there any other link i can see your sample?
Thanks.



MF Mauricio Feijo January 26, 2011 11:54 PM UTC

Could this link be refreshed please? I would like to look at these samples.



GC Grant Crofton February 17, 2011 03:22 PM UTC

I would also like to see the sample, as I'm having the same problem.



AV avinash March 25, 2011 04:44 PM UTC

The link is not working. please make sure that it works.



AV avinash April 1, 2011 08:09 PM UTC

Can somebody look into it. its urgent




LA Lakshmanan June 20, 2013 03:23 PM UTC

We are in the process of upgrading from 7.x to 10.3.0.43.  When we refresh a GroupingGrid in 10.3.0.43, we see that all the groups get collapsed (We didn’t see this behavior in 7.x). We found this forum article this post talking about the exact problem but the links are not working. Can some one post a working sample or updated link. We need this urgently

Thanks in advance



SA sagarika November 10, 2014 10:56 PM UTC

Hi,

Can you please provide a sample how you have achieved to maintain the state  of grid being enables or collapsed on refresh ?

Loader.
Live Chat Icon For mobile
Up arrow icon