Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger OnChangeCell Event

Tags:

slickgrid

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?


1 Answers

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.

like image 74
Tin Avatar answered Jul 22 '26 06:07

Tin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!