title: Kendo Grid: Removing dirty cell indicators
body: <p>I have been looking at a way to save off my client side edited grid data automatically when the user changes to another row (just like in access, sql management studio etc). It really seems to be a bit of a challenge to do.</p>
  
  <p>One scheme was to use the data source sync, but this ha the problem of loosing our cell position (it always jumped to cell 0, 0).</p>
  
  <p>I have been shown some clever work arounds (go back to the cell after the case, which by the way is hugely appreciated thanks), 
  but it after some lengthy testing (by myself and others) seemed to be a little "glitchy" (perhaps I just need to work on this more)</p>
  
  <p>At any rate, I wanted to explore perhaps not using this datasource sync and perhaps just do the server side calls "manually" (which is a bit is a pity, but if that's what we need to do, so be it). If I do this, I would want to reset the cell little red cell "dirty" indicators.</p>
  
  <p>I thought I could use something similar to  <a href="https://stackoverflow.com/questions/14762959/manually-maintain-dirty-cell-marker-on-paging-in-kendo-grid">this scheme</a> (except rather than resetting the flag, I want to unset).</p>
  
  <p>So, as in the above link, I have the following..</p>
  
  <pre><code> var pendingChanges = [];
  
   function gridEdit(e) {
     var cellHeader = $("#gridID").find("th[data-field='" + e.field + "']");
     if (cellHeader[0] != undefined) {
        var pendingChange = new Object();         
       pendingChange.PropertyName = e.field;        
       pendingChange.ColumnIndex = cellHeader[0].cellIndex;        
       pendingChange.uid = e.items[0].uid;
       pendingChanges.push(pendingChange);
      }
     }
  </code></pre>
  
  <p>where we call gridEdit from the datasource change..</p>
  
  <pre><code>var dataSrc = new kendo.data.DataSource({
  change: function (e) {
    gridEdit(e);
  },
  </code></pre>
  
  <p>Now assuming we have a callback that detects the row change, I thought I could do the following...</p>
  
  <pre><code>// clear cell property (red indicator)
  for (var i = 0; i &lt; pendingChanges.length; i++) {
    var row = grid.tbody.find("tr[data-uid='" + pendingChanges[i].uid + "']");
    var cell = row.find("td:eq(" + pendingChanges[i].ColumnIndex + ")");
  
    if (cell.hasClass("k-dirty-cell")) {
      cell.removeClass("k-dirty-cell");
  
      console.log("removed dirty class");
    }
  }
  
  pendingChanges.length = 0;
  
  // No good, we loose current cell again! (sigh..)
  //grid.refresh();
  </code></pre>
  
  <p>When this didn't work, I also tried resetting the data source dirty flag..</p>
  
  <pre><code>// clear dirty flag from the database
  var dirtyRows = $.grep(vm.gridData.view(),
    function (item) {
      return item.dirty == true;
    })
  
  if (dirtyRows &amp;&amp; dirtyRows.length &gt; 0) {
    dirtyRows[0].dirty = false;
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/peterjc/kozqnamd/1/" rel="nofollow noreferrer">demo here</a></p>
  
  <p>After none of the above worked, I tried the grid.refresh(), but this has the same problem as the datasource sync (we loose our current cell)</p>
  
  <p>Would anyone have any idea how I can clear this cell indicator, without refreshing the whole grid that seems to totally loose our editing context?</p>
  
  <p>Thanks in advance for any help!</p>