Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check if a Kendo Grid has had changes made to it?

Tags:

How can I check if a Kendo Grid has changes? I heard that there is a dirty property, but I cant find it.

like image 555
muthucsm Avatar asked Oct 04 '12 05:10

muthucsm


People also ask

How do I make my Kendo grid editable?

So, if NOC Code=='C01', then COR ABA No. is editable, otherwise it is not. I have achieved this by adding the Edit event on the columns and in that edit handler disabling the HTML input Kendo creates, when no editing is allowed. (In the grid definition, I have Editable(true) to start).

What is Pageable in kendo grid?

kendo:grid-pageable-messagesThe text messages displayed in pager. Use this option to customize or localize the pager messages. More documentation is available at kendo:grid-pageable-messages.

What is autoBind in kendo grid?

autoBind Boolean (default: true)By default, autoBind is set to true and the widget will bind to the data source specified in the configuration. Setting autoBind to false is useful when multiple widgets are bound to the same data source.


2 Answers

You can use the 'hasChanges' method on the Grid's underlying DataSource:

grid.dataSource.hasChanges();  $('#divGrid').data('kendoGrid').dataSource.hasChanges(); 
like image 64
Chris Pietschmann Avatar answered Oct 05 '22 19:10

Chris Pietschmann


Added rows will have the dirty property set to true and so will updated rows. But, deleted rows are stored elsewhere (in the _destroyed collection). Pass this function the datasource of your grid to see if it has changes.

function doesDataSourceHaveChanges(ds) {     var dirty = false;      $.each(ds._data, function ()     {         if (this.dirty == true)         {             dirty = true;         }     });      if (ds._destroyed.length > 0) dirty = true;      return dirty; } 
like image 33
carlg Avatar answered Oct 05 '22 19:10

carlg