When restoring grid's structure, dataBound is called 5 times

Hi

Please see the following. I added dataBound event with a simple console.log.

When opening/saving view/sorting column - dataBound event is called once.
When clicking on restore (view): dataBound is called 5 times!

Any reason for that?

3 Replies 1 reply marked as answer

SK Sujith Kumar Rajkumar Syncfusion Team July 1, 2020 11:32 AM UTC

Hi Amos, 
 
Greetings from Syncfusion support. 
 
The data bound event will be triggered on model change for grid actions such as, data bind, filter, search, page, sort, etc. So while restoring the entire persist data to the Grid it will restore all the settings in that including Filter, Sort, Search, Page and so when each of this is getting restored the model will be changed triggering the data bound event. This is the behavior of the Grid’s data bound event handler. You can prevent the multiple triggering of the data bound event handler while restoring Grid’s persist data by passing additional value – true along with the persist data to the setProperties method as demonstrated in the below code snippet, 
 
this.$refs.grid.ej2Instances.setProperties(this.savedProperties, true); 
 
 
Modified sample for your reference, 
 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 


Marked as answer

AM Amos July 1, 2020 11:45 AM UTC

Thanks, from the operational point of view it works as you explained.
Am I losing something from the functionality point of view?
I mean is there a reason for this multiple triggering that I'm losing because of that "true" parameter?

Thanks!


SK Sujith Kumar Rajkumar Syncfusion Team July 2, 2020 12:05 PM UTC

Hi Amos, 

The dataBound event will be triggered every time the current view data is modified to indicate the new data bind for grid actions such as, page, filter, sort, search, etc. When each of these actions is performed new data will be set as the Grid’s current view data and the data bound event will be triggered to notify that. So when these actions are updated using the persist data the dataBound will triggered for each of them as updated previously which is its default behavior. 

Let us know if you have any concerns. 

Regards, 
Sujith R 


Loader.
Up arrow icon