Reputation: 576
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 database. 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?
Upvotes: 1
Views: 2961
Reputation: 576
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;
}
....
Upvotes: 0
Reputation: 9082
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.
Upvotes: 2