We have a Grid set to popup edit mode, and Kendo internally calls editRow() when we click on an "Edit" command button we define in one of the columns.. As part of our row editing process, we would like to refresh the row's data in the datasource from the remote server, so that the user is editing fresh, current data for the row. It appears that even the beforeEdit event is too late for this, as the popup editor has already used the existing values in the data record, and getting the datasource to reload the data item the row uses won't affect the values displayed in the editor (although the datasource is indeed updated). So what we did in our beforeEdit() handler was something like this:
- call e.preventDefault(), which is intended to eventually cancel out the editRow() call that Kendo made from our button click.
- get as "row" the "tr" element from e.sender.tbody that has the
- run some code that updates the one item in the datasource (e.model) - the AJAX call is done in a deferred promise.
- in the then() handler of that, call e.sender.editRow(row), which should make a new editing call, replacing the one we aborted with preventDefault().
This may be a terrible hack, but it seemed to work with Kendo 2021.2.526. When we replaced that with Kendo 2025.1.227, it fails. We get a Javascript error like this:
Uncaught TypeError: Cannot read properties of undefined (reading 'parent')
at init.editRow (kendo.2025.1.227.all.min.js:9:1918996)
at init._editCommandClick (kendo.2025.1.227.all.min.js:9:1911991)
at HTMLDivElement.dispatch (jquery.min.js:3:12444)
at r.handle (jquery.min.js:3:9173)
and the editRow line is something like this:
a = r.editView ? r.editView.element : "popup" === s ? r._editContainer.parent() : r._editContainer,
where "r" is effectively "this", the grid widget. It looks like when Kendo does its own editRow() call, it may be stashing the popup window as "_editContainer", and does a .parent() dereference to get the grid container that it would get directly in the non-popup case. But when we make our own editGrid() call, either the context is slightly different and the Kendo code doesn't stash the popup window, or there's some extra state being kept in the newer Kendo code that isn't cleared by our preventDefault() call, and is still there when we make our own editRow() call before our beforeEdit handler returns control to Kendo, or something like that.
We could try either using our own button (which we would probably have to style to match the classes Kendo give the edit button it produces itself), which could call editRow(), or maybe attach a click handler to Kendo's button to do our data refresh before things continue on to Kendo's click handling, so that we get in there before Kendo calls editRow(). But I was wondering if there was some clean way of hooking into the row edit process to refresh our data before the popup window looks at it?