layui数据表格获取表格加载和重载数据的方法

在表格渲染完成后的回调函数中,定义一个全局变量exportData,让它取得表格中的数据集合。

使用 done - 数据渲染完的回调:

done: function(res,curr,count){
    exportData=res.data;
}

js代码(表格加载):

table.render({
    elem: '#tableId',
    url: './select.php',
    cols: [[
        {field: 'id', width: 50, title: '序号', type: 'numbers'},
        {field: 'user_id', width: 70, title: '用户ID', hide: true},
        {field: 'name', width: 110, title: '用户名'},
        ......
    ]],
    limits: [10, 15, 20, 25],
    limit: 15,
    page: true,
    even: true,
    done: function(res){
        console.log(res);
        exportData=res.data;
    }            
});

js代码(表格重载):

table.reload('currentTableId',{
    page: {
        curr: 1,
        limit: 15
    }, 
    where: {
        staff_name: staff_name
    },
    done: function(res){
        exportData=res.data;
    }
}, 'data');

return false;
});
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容