【发布时间】:2015-11-25 15:45:43
【问题描述】:
在可操作的 row_remove 上下文菜单中,是否可以在删除行之前附加确认消息,以便用户可以选择取消请求?
【问题讨论】:
在可操作的 row_remove 上下文菜单中,是否可以在删除行之前附加确认消息,以便用户可以选择取消请求?
【问题讨论】:
是的。在文档中有一个beforeRemoveRow,可用于在删除行之前调用函数。
您可以在表格的声明中使用它:
$(document).ready(function () {
var container = document.getElementById('basic_example');
var data = function () {
return Handsontable.helper.createSpreadsheetData(100, 12);
};
var hot = new Handsontable(container, {
data: data(),
height: 396,
colHeaders: true,
rowHeaders: true,
stretchH: 'all',
columnSorting: true,
contextMenu: true,
beforeRemoveRow: function(){return confirm("Are you sure you want to remove this row?")}
});
});
这里有一个Fiddle 的例子。
【讨论】: