layui.use(['table'], function () { $.post('/Test/TableGridQuery', {}, function (rsp) { var table = layui.table, tableId = 'tblInfo'; table.render({ id: tableId , elem: '#' + tableId , data: rsp.data , cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增 , cols: [[ { field: 'P_NO', width: 100, title: '页面编号' } , { field: 'P_NAME', width: 100, title: '页面名称' } , { field: 'P_ROLE', width: 100, title: '页面角色' } , { field: 'P_DESC', title: '页面说明' } , { field: 'P_URL', width: 280, title: '页面URL' } , { fixed: 'right', width: 120, align: 'center', templet: function () { return ' 编辑\ 删除'; } } ]] }); //监听数据操作(其中tableID就是页面中的lay-filter) table.on('tool(' + tableId + ')', function (obj) { var data = obj.data; if (obj.event === 'del') { layer.confirm('真的删除行么', function (index) { layer.msg('删除成功'); obj.del(); layer.close(index); }); } else if (obj.event === 'edit') { showEdit(data); } }); }, 'json'); });
}
|