I am using the grid in Batch edit mode (NOT Normal mode). I have a list of rows. When I change a value in one row, I want to examine all the current rows in the grid to perform some business logic. I need to see the data with the changes in it.
How can I get access to the current data in the grid which has all the changes made to it? This is a list of things I have attempted to do.
- getDataRows and getRows both return a list of elements, not actual data. I had seen examples using getRowObjectFromUID like this:
self.$refs.datagrid.ej2Instances.getRowObjectFromUID
But when I try to use it, the browser throws an error saying that getRowObjectFromUID is not found. When I examine the ej2Instances, I can see heaps of functions on there but not getRowObjectFromUID .
- dataSource is the original list of items I set for the grid and doesn't show me the changes.
- currentViewData has the original list of items as well.
- I thought to manually pull out the changes using getBatchChanges() but I can't find a suitable event for this. If I add it to the "rowSelected" event, that fires too much. When I try to add a row, I get the row added to the grid but then "rowSelected" fires and my code runs and the add goes all weird. What I need is a "endEdit" event that fires *once* when I move out of a row I just changed/added. There is a "beginEdit" event but in batch mode that never fires. And the doco doesn't have anything about an "endEdit". "actionComplete" doesn't have any events firing when I need them to.
In frustration, I thought to switch edit mode from Batch to Normal but then that had its own set of issues and didn't want to head down that path...
Help!
Thanks
Jeff
|
onCellSaved: function (args) {
// Current Grid data source
var curData = Object.assign([], this.$refs.grid.ej2Instances.dataSource);
// Batch changes
var changedRecords = this.$refs.grid.ej2Instances.getBatchChanges().changedRecords;
// The batch changes are updated in the retrieved Grid data source
changedRecords.forEach((dat) => {
var index = this.$refs.grid.ej2Instances.getRowIndexByPrimaryKey(dat["OrderID"]);
curData[index] = dat;
});
console.log(curData);
} |
Hi Sujith
I would have preferred something where I didn't have to do any work :-) but its a workable solution.
Thanks for your help
Cheers
Jeff