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

How to create a Grid State programmatically from server-side code?

7 Answers 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 06 Oct 2016, 01:27 PM

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

Sort by
0
Vladimir Iliev
Telerik team
answered on 10 Oct 2016, 07:29 AM
Hi Alex,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 11 Oct 2016, 01:15 PM

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.

0
Vladimir Iliev
Telerik team
answered on 13 Oct 2016, 08:24 AM
Hi Alex,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 13 Oct 2016, 04:37 PM

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.

0
Vladimir Iliev
Telerik team
answered on 14 Oct 2016, 07:42 AM
Hi Alex,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 14 Oct 2016, 01:21 PM

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?

 

0
Vladimir Iliev
Telerik team
answered on 17 Oct 2016, 07:37 AM
Hi Alex,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Alex
Top achievements
Rank 1
Share this question
or