Filter kendo grid from Query string parameters

2 posts, 0 answers
  1. Aktzc
    Aktzc avatar
    6 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2014 Link to this post

    Hi I have a kendo grid with server sorting, server filtering, server paging functionalities. Is there a way, where I can filter the grid from querystring parameters. Example:

    I have a kendo grid with First name, Last Name, Address etc columns. Now I have the following url:(the query string will be dynamic)

    localhost/Home/GetFilteredData?fname=tom&lname=William......

    Can we filter the grid based on the given query string? Also, can we save the state after filtering the grid and load it once this url is clicked again?

    Any help appreciated!! THANKS
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 28 Jul 2014 Link to this post

    Hello Aktzc,

    Generally speaking this is possible, but you will have to write custom JavaScript logic that parses the query string parameters into filter rules (e.g. JavaScript objects). For example:

    localhost/Home/GetFilteredData?fname=tom&lname=William
     
    //should be transformed into
    [
      { field: "fname", operator: "eq", value: "tom" },
      { field: "lname", operator: "eq", value: "William" }
    ]


    Once the filter rules array is build, you should pass it to the filter method of the DataSource.

    Regarding the saving grid's state question, I suggest checking this code library project as it demonstrates how to save the Grid's state in a cookie and restore it when the page is opened again.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top