开发者

slickgrid : how to know which rows are dirty

The slickgrid is pretty good! In disconnected mode, the user makes some changes. when the job is done the changes are to be saved on the server. I would like to know if there is a convenient way to update the d开发者_开发知识库atabase. the dataview contains the up-to-date data, is it aware of the changes that occurred since the loading (e.g. the deleted rows) or do we need to track on ourself the changes?


You can use the onCellChanged event or a custom editCommandHandler to mark rows as dirty and just make an Ajax call to update those rows. All of the more sophisticated synchronization is up to you - SlickGrid doesn't have any helpers for that.


I had no problem using onCellChanged event when possible.
Now I try to use onSelectedRowsChanged event to get the rowid of the row to be deleted.

But, the grid.getSelectedRows() only returns the row number on the current page. So I have a problem to get the rowid when the grid is filtered or doesn't display the first page.

I guess there is some dataset that manages the current view but I can't find it.

So what is the best solution to retrieve the rowid from row number according to the current view ? regards


Update:
I finally changed my mind by creating a function in grid.js that returns the rowid of the last selected row (not an array to allow only one row deletion)

  "getSelectedRowID":     getSelectedRowID,

that I use like this :

-> get the current row id

grid.onSelectedRowsChanged = function (e, args) {
    currentID = grid.getSelectedRowID();
    .....
    }

-> and delete this row if the delete key is pressed

grid.onKeyDown = function (e) {
      // delete key
      if (e.keyCode == 46) {
      if (confirm('confirmez-vous la suppression de la ligne : ' + currentID)) {
                dataView.deleteItem(currentID);
                deletedRowIds.push(currentID);
          }
          return true;
      }
   ....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜