简体   繁体   中英

KendoUI Grid inline edit: focus cell on doubleclick

I have a kendo grid in inline edit mode to which I bound a dblclick event which enables the doubleclicked line for edit and should also focus on the cell which was targeted by the doubleclick. I wrote the example in codepen, please see the following link: http://codepen.io/kpax/details/IyFab/

When the doubleclick is performed in the first two cells it works as expected. But if it's performed on the last three cells, the focus is placed in the first cell.

What am I missing?

Thanks a lot in advance for replies!

I think it has something to do with the amount of time it's taking the Kendo grid to change the formatting of the row. I was able to make this work with as little as a 10ms delay.

var timeout = 25;
setTimeout(function() {
    cell.find("input").focus();
}, timeout);

But even 50 or 100 ms did not produce a noticeable delay. It just has to be enough time for the browser to process the script that turns the normal row into an editable one (I think).

It seems as if the focus part of the grid's edit is async, so your focus works, but then the edit's focus takes place and you focus on the default (the first cell). Here's a working codepen: http://codepen.io/anon/pen/avApy All I did was to wrap the focus line with setTimeout to make sure it happens after the edit command is over completely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM