Kendo Grid - How to stop or prevent Databound event

Vicky picture Vicky · Mar 19, 2013 · Viewed 11.4k times · Source

I have Kendo grid as empty. Then I add one row, entering values and call saveRow() method. This will call controller and returns message, based on message I want to clear added(newly) record. I have used the code is: grid.dataSource.data([]); this code calling data bound event two times. I want this to be called only ONCE or I don't want to call Data bound event.. but I have to empty the grid.

Please advise.

Answer

Petur Subev picture Petur Subev · Mar 19, 2013

Hello you can try and use the requestEnd event of the dataSource - check that message which you return, prevent the next dataBinding of the Grid and set the data again to empty array. e.g.

function onRequestEnd(e){
     if()//some condition basedo on the e.response
     {
         $('#grid').data().kendoGrid.one('dataBinding',function(e){
                 e.preventDefault();
                 this.dataSource.data([]);
         })
     }
}