Kendo Grid: Trigger Update press enter button to press button for popup editing

I am using a Kendo UI Grid with pop-up editing. By default, when a user edits a field in a pop-up editor and enters the enter key, the data is transferred to the grid (behind the pop-up editor), but the pop-up window remains visible and the save event does not fire until you click Refresh.

I am trying to change this functionality, so when the user presses the input while editing the field, he calls the "Refresh" button - this means that he will display the data in the grid, trigger the save event and close the editor pop-up window.

My current attempt simply closes the popup editor, but does not fire a save event and discards changes made to any fields for the selected row. Instead, the Cancel button was clicked.

options.edit = function (e) {
    $('.k-edit-field .k-input').on('keypress', function (e) {
        utils.onEnter(e, function () {
            $('.k-grid-update').trigger('click');
        });
    });
};

How can I trigger a refresh button, or at least mimic what it does?

+5
source share
2 answers

I was unable to find the kendo method to make the changed fields become dirty and then save them, so I used a bit of jQuery and just switched focus to the refresh button and then raised the click event. Works as expected ...

options.edit = function (e) {
    $('.k-edit-field .k-input').on('keypress', function (e) {
        utils.onEnter(e, function () {
            $('.k-grid-update').focus().trigger('click');

        });
    });
};
+4
source

I would suggest using the saveRow method , which will save the current data and close the PopUp editor.

eg:.

$("#grid").data("kendoGrid").saveRow();
+2

All Articles