首页 > 解决方案 > 制表库和撤销功能

问题描述

我正在尝试将行菜单和标题菜单添加到我的表中。这两个函数都可以正常工作,但是函数 undo 不起作用并且函数 userTable.getHistoryUndoSize() 总是返回 0。当我手动编辑表中的数据时,撤消工作正常。有人可以帮助我做错什么吗?我正在使用最新的制表符 4.8.3

谢谢

var rowMenu = [{
    label:"Enable All Floors",      
    action:function(e, row){
        userTable.blockRedraw();                                                                    
        row.update({f1:true});row.update({f2:true});row.update({f3:true});row.update({f4:true});row.update({f5:true});row.update({f6:true});
        row.update({f7:true});row.update({f8:true});row.update({f9:true});row.update({f10:true});row.update({f11:true});row.update({f12:true});
        row.update({f13:true});row.update({f14:true});row.update({f15:true});row.update({f16:true});
        userTable.restoreRedraw();                                                                  
    }       
},
{
    label:"Disable All Floors",                                                                     
    action:function(e, row){
        userTable.blockRedraw();                                                                            row.update({f1:false});row.update({f2:false});row.update({f3:false});row.update({f4:false});row.update({f5:false});row.update({f6:false});
        row.update({f7:false});row.update({f8:false});row.update({f9:false});row.update({f10:false});row.update({f11:false});row.update({f12:false});
        row.update({f13:false});row.update({f14:false});row.update({f15:false});row.update({f16:false});
        userTable.restoreRedraw();                                                                  
    }
}
]

var headerMenu = [{
    label:"Set All in column to ON",
    action:function(e, column){
        userTable.blockRedraw();                                                                    
        rows.forEach(function(row){
            row.update({AL :true});                                                         
        }); 
        userTable.restoreRedraw();                                                                  
    }
},
{
    label:"Set All in column to OFF",
    action:function(e, column){
        userTable.blockRedraw();                                                                    
        rows.forEach(function(row){
            row.update({AL:false});                                                                 
        }); 
        userTable.restoreRedraw();                                                                  
    }
}]

dataChanged:function(data){
    console.log("data in table edited");    
    document.getElementById( 'undoBadge' ).innerHTML = userTable.getHistoryUndoSize();
    document.getElementById('BTNundoData').removeAttribute("disabled");
    PreventLoseData = true;                                                                
},

标签: javascripttabulator

解决方案


推荐阅读