如何取消制表符中的编辑
how to Cancel Edit in tabulator
在编辑任何行的数据后如何允许用户取消编辑的数据返回到原始数据,
无法重新加载整个 table 因为这将取消所有编辑的行,我只需要取消一行
撤消函数 "table.undo();" 需要多次调用才能撤消整行,是否有类似 "row.undo();" 的东西
我想编码看起来像 blow
var ivInvGRNDGrid = new Tabulator("#ivInvGRNDGrid", {
ajaxURL: "/abc/abcd/GetData",
layout: "fitColumns",
index: "id",
columns: [
{ title: "Delete", formatter: DeleteIcon, width: 40, align: "center", cellClick: function (e, cell) { ivInvGRNDDelete(cell.getRow().getData().id); }, headerSort: false },
{ title: "Cancel Edit", formatter: UndoIcon, width: 40, align: "center", cellClick: function (e, cell) { row.undo(); }, headerSort: false },
{ id: "ID", title: "@Localizer["ID"]", field: "iD", headerToolTip: "@Localizer["IDtip"]", validator: "required", editor: "number", visible: false, sorter: "number", editable: Editable },
{ id: "ItemID", title: "@Localizer["ItemID"]", field: "itemID", headerToolTip: "@Localizer["ItemIDtip"]", validator: "required", editor: "number", validator: "required", minWidth: 120, editable: Editable },
],
});
恐怕没有行撤消功能,但您可以通过调用 restoreOldValue 恢复单元格的先前值在细胞成分上。所以在取消编辑行的 cellClick 函数中你可以这样做:
function(e, cell){
cell.getRow().getCells().forEach(function(cell){
var oldVal = cell.getOldValue();
if(oldVal !== null){
cell.restoreOldValue();
}
})
}
在编辑任何行的数据后如何允许用户取消编辑的数据返回到原始数据,
无法重新加载整个 table 因为这将取消所有编辑的行,我只需要取消一行
撤消函数 "table.undo();" 需要多次调用才能撤消整行,是否有类似 "row.undo();" 的东西
我想编码看起来像 blow
var ivInvGRNDGrid = new Tabulator("#ivInvGRNDGrid", {
ajaxURL: "/abc/abcd/GetData",
layout: "fitColumns",
index: "id",
columns: [
{ title: "Delete", formatter: DeleteIcon, width: 40, align: "center", cellClick: function (e, cell) { ivInvGRNDDelete(cell.getRow().getData().id); }, headerSort: false },
{ title: "Cancel Edit", formatter: UndoIcon, width: 40, align: "center", cellClick: function (e, cell) { row.undo(); }, headerSort: false },
{ id: "ID", title: "@Localizer["ID"]", field: "iD", headerToolTip: "@Localizer["IDtip"]", validator: "required", editor: "number", visible: false, sorter: "number", editable: Editable },
{ id: "ItemID", title: "@Localizer["ItemID"]", field: "itemID", headerToolTip: "@Localizer["ItemIDtip"]", validator: "required", editor: "number", validator: "required", minWidth: 120, editable: Editable },
],
});
恐怕没有行撤消功能,但您可以通过调用 restoreOldValue 恢复单元格的先前值在细胞成分上。所以在取消编辑行的 cellClick 函数中你可以这样做:
function(e, cell){
cell.getRow().getCells().forEach(function(cell){
var oldVal = cell.getOldValue();
if(oldVal !== null){
cell.restoreOldValue();
}
})
}