我可以通过 "insert" 键在 handsontable 中添加行吗?
Can I add row in handsontable by "insert" key.?
我想通过 "insert" 键在 handsontable 中添加一行。是否可以通过键添加行。
是的,你可以。您需要做的是首先捕获 "insert" 键事件。然后调用 handsontable 实例并使用 alter ('insert_row', index, amount)
,其中 index 是您想要的位置(例如,将其设置为 0 以添加到顶部),amount 是空行的数量。
应该是这样。
这是我的代码,它运行良好..:)
$(document).keyup(function(e) {
if (e.keyCode == 45) {
var rowIndex = $('.currentRow').parent().index();
hot.alter("insert_row", rowIndex);
}
}); //insert key
".currentRow" 是我当前选择的行 class,当前行 tr > td。
这就是为什么我使用 $('.currentRow').parent()
因为我想得到 tr 索引。
我想通过 "insert" 键在 handsontable 中添加一行。是否可以通过键添加行。
是的,你可以。您需要做的是首先捕获 "insert" 键事件。然后调用 handsontable 实例并使用 alter ('insert_row', index, amount)
,其中 index 是您想要的位置(例如,将其设置为 0 以添加到顶部),amount 是空行的数量。
应该是这样。
这是我的代码,它运行良好..:)
$(document).keyup(function(e) {
if (e.keyCode == 45) {
var rowIndex = $('.currentRow').parent().index();
hot.alter("insert_row", rowIndex);
}
}); //insert key
".currentRow" 是我当前选择的行 class,当前行 tr > td。
这就是为什么我使用 $('.currentRow').parent()
因为我想得到 tr 索引。