How to set grid options on load

6 posts, 1 answers
  1. Austen
    Austen avatar
    9 posts
    Member since:
    Aug 2018

    Posted 24 Aug 2018 Link to this post

    I have a remote binding grid that is used to access several different external tables. I have a button that can apply a users saved options for the grid using the setOptions method. The issue I'm having is trying to get the grid to apply the users options when the data is loaded; ie the user clicks to a different table and the grid auto applies the options. My first attempt was using the dataBound event to call my setOptions method to apply the configuration, however this does not fire and is actually listed as not being possible in the documentation here: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/setoptions 

     

    How can I get around this to have the setOptions method be called on a grid loading? 

     

    Thanks.

  2. Josh
    Josh avatar
    7 posts
    Member since:
    Oct 2014

    Posted 24 Aug 2018 in reply to Austen Link to this post

    Just call your set options function on the button click. This will cause the grid to refresh itself with the new settings.
  3. Answer
    Josh
    Josh avatar
    7 posts
    Member since:
    Oct 2014

    Posted 24 Aug 2018 in reply to Josh Link to this post

    Josh said:Just call your set options function on the button click. This will cause the grid to refresh itself with the new settings.

    By button click, I mean when the user selects the "table" then call the setoptions function

     

     

  4. Austen
    Austen avatar
    9 posts
    Member since:
    Aug 2018

    Posted 24 Aug 2018 Link to this post

    Not the cleanest solution since it does require a setTimeout() to avoid it calling the method before the grid is loaded, but that does work nicely!

     

    Thanks.

  5. Josh
    Josh avatar
    7 posts
    Member since:
    Oct 2014

    Posted 24 Aug 2018 in reply to Austen Link to this post

    Hello, I am not sure if this is applicable to your situation, but you might be able to avoid using setTimeout() by setting the autobind property on the grid to false.

    https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/autobind

    This will prevent the grid from loading data when it is initialized. It will then load the data when your user selects the table and the setOptions method is called.

     

     

  6. Preslav
    Admin
    Preslav avatar
    591 posts

    Posted 28 Aug 2018 Link to this post

    Hello,

    I can confirm that Josh's suggestion about setting the autoBind configuration to false is the correct way of preventing the Grid from doing two read requests.


    Regards,
    Preslav
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top