I have a grid called unitsGrid
that is functioning correctly. I am able to add and delete rows, but the issue arises when I try to delete rows - they do not disappear from my unitsGrid. I have spent hours trying to debug the code but I cannot seem to find the problem.
Thank you in advance.
dojo.connect(unitsGrid, "onRowClick", unitsGrid, function(evt, rowIndx, fieldIndx){
var idx = evt.rowIndex;
var item = this.getItem(idx);
var id = unitsGrid.store.getValue(item, "id");
if(evt.cellIndex == 3) {
var con = confirm("Are you sure you want to delete this transaction?");
if(con == true) {
dojo.xhrPost({
url: url,
content: {
id: id
},
handleAs: "text",
load: function(data) {
var selectedRows = grid.selection.getSelected();
if (selectedRows.length) {
// Iterate through the list of selected items.
// The current item is available in the variable
// "selectedItem" within the following function:
dojo.forEach(selectedRows, function(selectedItem) {
if (selectedItem !== null) {
// Delete the item from the data store:
try {
unitsGrid.store.deleteItem(selectedItem);
}
catch(error) {
console.log("Returned error: " + error.message);
}
} // end if
}); // end forEach
} // end if
console.log("Return value: " + data);
},
error: function(error) {
console.log(error);
}
}); // end xhrPost
}
}
});