Slickgrid - Lost focus to end edit

sunzyflower picture sunzyflower · Mar 19, 2013 · Viewed 7.6k times · Source

When editing my grid, if I click outside the grid, the box I was editing is still editable. How do I get the edited cell to "complete" the edit when it looses focus?

Answer

clav picture clav · Mar 20, 2013

The following code will save the current edit.

Slick.GlobalEditorLock.commitCurrentEdit();

You'll need to place this inside an event handler that you think should trigger the save. For example, if you're using the sample text editor plugin, I believe an editor-text CSS class is added to the input field that's created when you're editing a cell so something like this should work:

$('#myGrid').on('blur', 'input.editor-text', function() {
    Slick.GlobalEditorLock.commitCurrentEdit();
});