Giter Club home page Giter Club logo

how-to-save-and-reload-filters-in-winui-datagrid's Introduction

How to save and reload filters in WinUI DataGrid?

About the sample

This example describes how to save and reload filters in WinUI DataGrid.

WinUI DataGrid (SfDataGrid) allows to save and load the grid settings using the SfDataGrid.Serialize and SfDataGrid.Deserialize methods. This process can be customized by passing SerializationOptions and DeserializationOptions as parameters to these methods. SerializationOptions and DeserializationOptions contains a set of properties that is used to customize the serialization/deserialization process.

Filters applied to the DataGrid can be saved by enabling the serialization of filters by setting SerializationOptions.SerializeFiltering property as illustrated in the following code example.

private void OnSerializeClicked(object sender, RoutedEventArgs e)
{
      if (dataGrid == null) return;
      var serializationOptions = new SerializationOptions()
      {
            SerializeFiltering = true,
      };
      using (var file = File.Create("DataGrid.xml"))
      {
            dataGrid.Serialize(file, serializationOptions);
      }
}

In the same way, the deserialization of serialized filters can be performed by enabling DeserializationOptions.DeserializeFiltering property as illustrated in the following code example.

private void OnDeserializeClicked(object sender, RoutedEventArgs e)
{
      if (dataGrid == null) return;
      var deserializationOptions = new DeserializationOptions()
      {
           DeserializeFiltering = true,
      };
      using (var file = File.Open("DataGrid.xml", FileMode.Open))
      {
           if (deserializationOptions.DeserializeFiltering == true)
           {
               dataGrid.Deserialize(file, deserializationOptions);
           }
      }
}

Serialization and Deserialization applied in SfDataGrid

Take a moment to peruse the WinUI DataGrid - Serialization and Deserialization documentation, where you can find about serialization and deserialization with code examples.

Requirements to run the demo

Visual Studio 2019 and above versions

how-to-save-and-reload-filters-in-winui-datagrid's People

Contributors

amalrajumapathyselvam avatar sarubala20 avatar syncfusionbuild avatar vijayarasan avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vijayarasan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.