Initialize Grid Options from Serialized JSON String

4 posts, 0 answers
  1. The Bearded One
    The Bearded One avatar
    6 posts
    Member since:
    Oct 2014

    Posted 19 Feb 2015 Link to this post

    We allow our users to optionally save the state of their grids and persist them in the db. When a user comes back to he screen, they see the standard grid display just for a moment, then it updates their grid via JavaScript ( setOptions call) as it applies their persisted state settings. This makes it look like it's doing a double load. 

    We would rather just initialize the grid with their persisted settings (via serialized json string) so the grid shows correctly on the initial load.

    Is this possible?

    We are using MVC.

    Thanks!
  2. Dimo
    Admin
    Dimo avatar
    8475 posts

    Posted 23 Feb 2015 Link to this post

    Hi Mark,

    The desired behavior is possible to achieve if you modify your implementation to avoid the unconditional Grid initialization with the default settings of the server declaration. There are two ways to do that:

    1. Replace the MVC wrapper with a client-side Grid and execute the Javascript initialization statement conditionally.

    2. Defer the Grid initialization statement, which is rendered by the MVC wrapper and wrap it in a condititonal statement.

    http://docs.telerik.com/kendo-ui/aspnet-mvc/fundamentals#deferred-initialization

    Generally, when working with Grid states, it is simpler to use the client-side Grid widget, because otherwise you are likely to end up with supporting two types of initialization at the same time.

    Regards,
    Dimo
    Telerik

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. The Bearded One
    The Bearded One avatar
    6 posts
    Member since:
    Oct 2014

    Posted 23 Feb 2015 in reply to Dimo Link to this post

    Thanks for the tips!

    If I change to a client side grid widget and do initialization there, which method(s) do I use to initialize the grid with my persisted state settings? I did not see a way to send in my serialized string.

    Thanks again...
  4. The Bearded One
    The Bearded One avatar
    6 posts
    Member since:
    Oct 2014

    Posted 23 Feb 2015 in reply to The Bearded One Link to this post

    Wait a moment, I would just use the setOptions method I'm already using! Never mind :)

    The rule to note here is not to post questions before the first cup of coffee!

    Thanks for the help!
Back to Top