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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

133056 Oct 6,2017 03:07 AM Oct 9,2017 11:59 AM WPF 1
loading
Tags: SfDataGrid
BAO YADONG
Asked On October 6, 2017 03:07 AM

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.

Gnanasownthari Thirugnanam [Syncfusion]
Replied On October 9, 2017 11:59 AM

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. 
 


CONFIRMATION

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.

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.

;