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

Save and Restore visible cells in a gridGroupingControl

Hello,

I am using a gridGroupingControl. I would like have some kind of way in which I can get the list of rows that are currently visible by the user, and then at a later time restore them.

Here is the situation. In my app, there are cases where the DataSource for the grid needs to be refreshed. After refreshing the datatable, we reset the datasource for the grid. However, when this occurs, the display scrolls up to the first row. I would like to make it so we can move back to the row that the user was previously looking at.

Thanks


5 Replies

SR Sri Rajan Syncfusion Team July 16, 2008 08:53 AM UTC

Hi Michael,

Thank you for your interest in Syncfusion products.

The GridGroupingControl retains the selections normally. Please refer the below sample in which GridGroupingControl retains the selection in the recently visible row eventhough new rows are added in the datatable.

http://websamples.syncfusion.com/samples/grid.windows/F75191/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.



AD Administrator Syncfusion Team July 16, 2008 01:25 PM UTC

It looks like i figured out the issue:

I wanted the ability to preserve the expanded groups before and after the refresh. For some reason, if I first refreshed the Grid, and then looped through all of the top level groups and only expanded the previously open ones, this situation occurred.

However, if I moved the refresh and the expansion of the groups into one step, and enclosed them in a grid.BeginUpdate() and grid.EndUpdate() block, the screen position was maintained, and the previously expanded groups were restored.



SR Sri Rajan Syncfusion Team July 17, 2008 11:10 AM UTC

Hi Michael,

Thank you for your Update.

You can also preserve the expanded groups using serialization concept.Please refer the below browser sample for more details.

Grid.Grouping Samples--->Serialization--->XML Serialization

Path In Disc:
\My Documents\Syncfusion\EssentialStudio\{Version Number}\Windows\Grid.Grouping.Windows\Samples\2.0\Serialization\XML Serialization

Please let me know if this helps.

Best Regards,
Srirajan.



MB Marcus Benz March 20, 2018 10:53 AM UTC

Hi,

the example is not available.

Thanks


SN Sindhu Nagarajan Syncfusion Team March 21, 2018 04:36 PM UTC

Hi Marcus, 
 
Thanks for the update.  
 
GridGroupingControl does not have direct support to serialize/de-serialize the record selection state. It can be achieved by creating custom class to hold the information of the selected record state. Please refer to the below  code and sample, 
 
Code Example 
private void serializeBtn_Click(object sender, EventArgs e) 
{ 
    //To serialize the selected record 
    List<GroupExpandState> groupExpandState = new List<GroupExpandState>(); 
    List<RecordSelectionState> recordSelectionState = new List<RecordSelectionState>();     
    foreach (SelectedRecord record in this.gridGroupingControl1.Table.SelectedRecords) 
    { 
        recordSelectionState.Add(new RecordSelectionState() { RecordIdentifier = this.gridGroupingControl1.Table.Records.IndexOf(record.Record), IsSelected = true }); 
    } 
    XmlSerializer serializer1 = new XmlSerializer(typeof(List<RecordSelectionState>)); 
    serializer.Serialize(xw, groupExpandState); 
    serializer1.Serialize(xw1, recordSelectionState); 
    xw.Close(); 
    xw1.Close();           
} 
 
private void deSeralizeBtn_Click(object sender, EventArgs e) 
 {    
     // To deserialize the selected record 
     XmlReader xr1 = new XmlTextReader("RecordSelectionState.xml"); 
     XmlSerializer serializer1 = new XmlSerializer(typeof(List<RecordSelectionState>)); 
     List<RecordSelectionState> selectionState = serializer1.Deserialize(xr1) as List<RecordSelectionState>;     
      
     foreach (RecordSelectionState recordSelectionState in selectionState) 
     { 
         this.gridGroupingControl1.Table.SelectedRecords.Add(this.gridGroupingControl1.Table.Records[recordSelectionState.RecordIdentifier]); 
     } 
 } 
 
 
 
Please refer to the dashboard sample available in your local machine 
<Installed Location>\Syncfusion\EssentialStudio\<Version number>\Windows\Grid.Grouping.Windows\Samples\Serialization\XML Serialization Demo\CS 
 
Please let us know your exact scenario so that solution can be provided at earliest. 
 
Regards, 
Sindhu  


Loader.
Live Chat Icon For mobile
Up arrow icon