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

8 posts, 0 answers
  1. Alex
    Alex avatar
    18 posts
    Member since:
    May 2015

    Posted 06 Oct Link to this post

    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?

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 10 Oct Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alex
    Alex avatar
    18 posts
    Member since:
    May 2015

    Posted 11 Oct in reply to Vladimir Iliev Link to this post

    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.

  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 13 Oct Link to this post

    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
  6. Alex
    Alex avatar
    18 posts
    Member since:
    May 2015

    Posted 13 Oct in reply to Vladimir Iliev Link to this post

    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.

  7. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 14 Oct Link to this post

    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
  8. Alex
    Alex avatar
    18 posts
    Member since:
    May 2015

    Posted 14 Oct Link to this post

    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?

     

  9. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 17 Oct Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready