Is there a way to build a GridState from server-side code?
We want to be able to set up the grid in a specific based on certain filters that are in a database. As far as I can tell the only way I could do that now is to look at how the structure of the JSON object is formed and create my own JSON object Grid State constructor based on that. But I don't like that idea because the structure could change with time, or there might be small things that I miss.
I'm looking for something along the lines of this:
GridState gs = new GridState();
gs.addFilter("columnName","filterText", columnWidth, showColumn, ..., .., )
Does anything like this exist?
7 Answers, 1 is accepted
I would suggest to check the following examples for more information about how you can achieve the desired behavior:
Regards,
Vladimir Iliev
Telerik by Progress
Sorry, I should have been more clear. I am trying to convert a bunch of values that are NOT related to Telerik in any way, into filters that can be read by the telerik grid.
So, I really do need to be able to build a Grid State object manually, and not just save it and load it from the database. I have already figured out how to save and load settings to and from the database. I just need to know how to build a Grid State object from scratch.
I'm still not sure that I fully understand the exact scenario that you have - could you please elaborate more on it? Do yo need to just filter the data on the server side or you need to send the filters to the client side where to be applied to the Grid options?
Regards,
Vladimir Iliev
Telerik by Progress
I need to be able to send the filters to the clien side and apply them to the grid. The problem is that I don't have any filters that are in a format at all similar to how Telerik stores filters. I essentially just have a lookup table that has a column and the filter to be applied.
For instance,
ColumnName | FilterValue
Owner | Sarah
DateBought | 5/26/2015
How can I build the JSON object to pass to the client? I already know how to store and retrieve filters that are generated by grid, but I don't know how to build the filter object when it's a filter I'm creating from data that has nothing to do with Telerik.
You can check the filter object structure used by the Grid dataSoure on the client-side in the dataSource client-side API:
Regards,
Vladimir Iliev
Telerik by Progress
Is there any other way to create that object? I really don't like the idea of having to hardcode the structure of the object.
Has the topic of importing filters into Kendo been discussed? Is there an alternative method I haven't considered?
There is no build in way to map custom filters to the dataSource "filter" field - that why you should implement this mapping using custom code.
As for the object structure on the server side you can check the "IFilterDescriptor" interface used inside the "DataSourceRequest" object for mapping the client-side the filters.
Regards,
Vladimir Iliev
Telerik by Progress