This is a migrated thread and some comments may be shown as answers.

Filter kendo grid from Query string parameters

1 Answer 966 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aktzc
Top achievements
Rank 1
Aktzc asked on 24 Jul 2014, 04:26 PM
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

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Jul 2014, 10:49 AM
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!
 
Tags
Grid
Asked by
Aktzc
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or