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

Save and Load filters in SFDatagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

116242 May 2,2014 09:50 AM UTC May 13,2014 12:43 PM UTC WinRT 1
loading
Tags: SfDataGrid
Kevin Kuan
Asked On May 2, 2014 09:50 AM UTC

Hi,

Is there anyway i can capture all the filters apply on the excel like filtering, stored the filters in an object, and load the object back into the filters any time i want later on?

Thanks and best regards,
Kevin


Ashok N [Syncfusion]
Replied On May 13, 2014 12:43 PM UTC

Hi Kevin,

Thanks for using Syncfusion Products.

You can achieve your requirement by serializing and de-serializing FilterPredicate in sample level. We have created the sample to achieve your requirement. Please find the sample in the following link.

Sample: http://www.syncfusion.com/downloads/support/directtrac/124663/DataGridFiltering31740703.zip

In this sample we have used SerializeFilters extension method for serialization operation in that method we serialize the filter predicate each column and store in xml file. For Deserialization we use DeserializeFilters extension method, and in that method we de-serialize xml file and set the filter predicate back to grid columns.

Serialization:

private async void Button_Click_1(object sender, RoutedEventArgs e)

{

    try

    {

        var folder = KnownFolders.DocumentsLibrary;

        var storageFile = await folder.CreateFileAsync("Filters.xml", CreationCollisionOption.ReplaceExisting);

        this.datagrid.SerializeFilters(storageFile);

    }

    catch (Exception)

    {

        //throw;

    }

}

 

Deserialization:

private async void Button_Click_2(object sender, RoutedEventArgs e)

{

    try

    {

        var folder = KnownFolders.DocumentsLibrary;

        var storageFile = await folder.GetFileAsync("Filters.xml");

        this.datagrid.DeserializeFilters(storageFile);

    }

    catch (Exception)

    {

        //throw;

    }

}

 

Please let us know if you have any queries.

Thanks,

Ashok


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.

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

;