Can i save and load selected column from database for ColumnChooser feature?

Hi,

Can i know how can i save and load the selected column preference when using ColumnChooser feature?

Lets say, the first time loaded, i have 3 columns displayed. user added 5 additional columns. i would like to do a save to database for this user, so the next time the user comes back to this screen, he will see 8 columns in total.

Is this feature supported?

Thanks.

1 Reply

GT Gnanasownthari Thirugnanam Syncfusion Team October 9, 2017 03:59 PM UTC

Hi YADONG, 

You can save the state of SfDataGrid using serialization and deserialization. 

private void Searilize(object sender, RoutedEventArgs e) 
{ 
    using (var file = File.Create("SfDataGrid.xml")) 
    { 
        //Serialize the file. 
        dataGrid.Serialize(file); 
    } 
} 
 
private void Deserialize(object sender, RoutedEventArgs e) 
{ 
    using (var file = File.Open("SfDataGrid.xml", FileMode.Open)) 
    { 
        //Deserialize the file 
        dataGrid.Deserialize(file); 
    } 
} 

Now we have prepared the sample by adding columns from column chooser and save the state by using serialization and deserialization while move to next page and come back to the same screen based on your requirement, you can download the same from below mentioned location. 

Sample location. 

Please refer the below UG link for more details about serialization and deserialization. 


Regards, 
Gnanasownthari T. 
 


Loader.
Up arrow icon