This is a migrated thread and some comments may be shown as answers.
How to set grid options on load
5 Answers 97 Views
This is a migrated thread and some comments may be shown as answers.
Austen
Top achievements
Rank 1
Austen asked on 24 Aug 2018, 06:03 PM

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.

5 Answers, 1 is accepted

Sort by
0
Josh
Top achievements
Rank 1
answered on 24 Aug 2018, 08:13 PM
Just call your set options function on the button click. This will cause the grid to refresh itself with the new settings.
0
Accepted
Josh
Top achievements
Rank 1
answered on 24 Aug 2018, 08:16 PM

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

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

 

 

0
Austen
Top achievements
Rank 1
answered on 24 Aug 2018, 08:33 PM

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.

0
Josh
Top achievements
Rank 1
answered on 24 Aug 2018, 08:55 PM

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.

 

 

0
Preslav
Telerik team
answered on 28 Aug 2018, 01:07 PM
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.
Tags
Grid
Asked by
Austen
Top achievements
Rank 1
Answers by
Josh
Top achievements
Rank 1
Austen
Top achievements
Rank 1
Preslav
Telerik team
Share this question
or