问题描述
Handsontable 为选择单元格时提供了一些不错的钩子,但我似乎无法找到方法来让我在单元格被选中时强制它进入编辑模式.
Handsontable provides some nice hooks for when a cell is selected but I can't seem to figure out way to get it to allow me to force a cell into edit mode when it has been selected.
我可以像这样检测单元格选择:
I can detect the cell selection like this:
Handsontable.PluginHooks.add( 'afterSelection', function( row, column ) {
var current_td = this.getCell( row, column );
});
我什至可以从那里获得被选中的单元格元素.但是从那里我似乎无法触发单元格进入编辑模式(其中有一个主动选择的 textarea 字段).这通常由双击触发.做显而易见的事情似乎不起作用:
And from there I can even obtain the cell element that was selected. But from there I can't seem to trigger the cell into edit mode (where it has an actively selected textarea field inside of it). This is normally triggered by a double click. Doing the obvious doesn't seem to work:
Handsontable.PluginHooks.add( 'afterSelection', function( row, column ) {
var current_td = this.getCell( row, column );
$(current_td).dblclick();
});
还有其他人做过这个或对我如何让它工作有想法吗?
Anyone else ever done this or have thoughts on how I might get it to work?
推荐答案
我相信我已经回答了我自己的问题:
And I believe I've answered my own question:
Handsontable.PluginHooks.add( 'afterSelectionEnd', function() {
f2_event = $.Event( 'keydown', { keyCode: 113 } );
this.$table.trigger(f2_event);
});
这似乎可以解决问题.
这篇关于使用 Handsontable 时如何强制选定单元格进入编辑模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!