如何取消制表符中的编辑

时间:2019-01-11 12:25:47

标签: tabulator

在任意行中编辑数据后,如何允许用户取消已编辑的数据以返回到原始数据, 无法重新加载整个表格,因为这将取消所有已编辑的行,我只需要取消一行
撤消功能“ table.undo();”需要多次调用才能撤消整行,是否有类似“ row.undo();”的内容 我想编码看起来像打击

 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 },


                ],

            });

1 个答案:

答案 0 :(得分:1)

恐怕没有行撤消功能,但是您可以通过调用单元格组件上的 restoreOldValue 来恢复单元格的先前值。因此,在取消编辑行上的 cellClick 函数中,您可以执行以下操作:

function(e, cell){
    cell.getRow().getCells().forEach(function(cell){
        var oldVal = cell.getOldValue();

        if(oldVal !== null){
            cell.restoreOldValue();
        }
    })
}