user599592
user599592

Reputation: 11

SlickGrid onCellChange after edits shown in example 7

If I add the following code to SlickGrid example 7:

grid.onCellChange.subscribe(function(e,args) 
{
  alert("here");
});

The alert appears if I update the text field, 'Title'. It does not when I update the 'Priority' field, which is being used to demonstrate click to toggle values. Clicks are captured with this code.

    grid.onClick.subscribe(function(e) {
       var cell = grid.getCellFromEvent(e);
       if (columns[cell.cell].id == "priority") {
          var states = { "Low": "Medium", "Medium": "High", "High": "Low" };
          data[cell.row].priority = states[data[cell.row].priority];
          grid.updateRow(cell.row);
          e.stopPropagation();
       }
    });

Question: How do I trigger onCellChange when the 'Priority' value changes?

Thank you to anyone who can help. John.

Upvotes: 1

Views: 8055

Answers (2)

paradox
paradox

Reputation: 71

How about just using JQuery with the $(#priority).change selector?

So here is how it would look (or something similar):

$("#priority").change(function(e) {
    var cell = grid.getCellFromEvent(e);
    var states = { "Low": "Medium", "Medium": "High", "High": "Low" };
    data[cell.row].priority = states[data[cell.row].priority];
    grid.updateRow(cell.row);
    e.stopPropagation();
    });

You probably want to change it to use a class instead of an id though, as each DOM id is supposed to remain unique per page.

Upvotes: 1

Tin
Tin

Reputation: 9082

Makes perfect sense to me. The event is raised by the grid only if the action was initiated within the grid. In your second example, you are making the change yourself directly against the data source by intercepting specific click events.

Upvotes: 1

Related Questions