I am using a variation of SlickGrid's Example 7 that allows a value to be selected from a list upon double clicking a cell. However this method does not fire the onCellChange event and I am not catching all the changes to the data. Below is a sample of the code.
grid.onDblClick.subscribe(function (e) {
e.preventDefault();
var cell = grid.getCellFromEvent(e);
if (grid.getColumns()[cell.cell].id != "classID") {return};
$("#contextMenu")
.data("row", cell.row)
.css("top", e.pageY)
.css("left", e.pageX)
.show();
$("body").one("click", function () {
$("#contextMenu").hide();
});
$("#contextMenu").click(function (e) {
if (!$(e.target).is("li")) {return};
var row = $(this).data("row");
data[row].classID = $(e.target).attr("data"); //< data saved to grid here
grid.updateRow(row);
});
});
Any sugestions as how to trigger the onCellChange function?
Nor should it really.
Think about it - the grid fires that event if the user initiates the action from within the grid. How would it know that you changed something externally/programmatically?
Just move your handling of the change event into a separate function and call that from both your onCellChange handler and places where you directly update the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With