Dinesh
Dinesh

Reputation: 53

how to revert single edited row in dojo dgrid?

Is there a way to revert/reset the edited row in the dojo-dgrid ?

I can see the grid.revert() which does clear the dirty items and calls the refresh method, which will refresh the whole grid. I don't want this whole grid-refresh.

Is it possible to reset/revert only that single edited row, upon clicking a Revert/Cancel Icon on the Actions-column (which will be the last column in the grid as mentioned here and here)

Upvotes: 0

Views: 1217

Answers (1)

Ivo Silva
Ivo Silva

Reputation: 350

If you're wrapping your store with Observable, you can use notify() to update a single row.

For example, you can create the following code for onClick event of your Revert/Cancel button:

 renderCell: function(object, data, cell){

   var btnRevert = new Button({
     label: "Revert",
     // ...
     onClick: function(evt){
       var dirty = that.grid.dirty,
           id = object.id;

       if(dirty.hasOwnProperty(id)){
         // remove dirty data
         delete dirty[id];
         // ..and notify the store to update
         myStore.notify(object, object.id);
       }
     }
   }, cell.appendChild(put("div")) );

   return btnRevert;
 }

Here is a jsfiddle with an example: revert example

Upvotes: 2

Related Questions