layui框架学习记录

时间:2024-11-26 16:36:02

自定义layui动态渲染的数据表格单元格样式

layui.use('table', function() {
var table = layui.table; table.render({
elem: "#table",
url: "{:url('xxxx')}",
page: true,
done: function(res) {
},
cols: [[
{field: 'id', title: 'ID', width: 80, sort: true, align: 'center'},
{field: 'xx', title: 'xx', sort: true,width: 120, align: 'center'},
{field: 'xx', title: 'xx', sort: true,width: 120, align: 'center'},
{field: 'xx', title: 'xxx', sort: true,width: 180, align: 'center'},
{field: 'xx', title: 'xx', style:'color:red', sort: true,width: 180, align: 'center'},
{title: '操作', width: 120, align: 'center', templet: '#operation'}
]]
}); // 监听工具栏
table.on('tool(table)', function(o) {
var d = o.data,
lEv = o.event,
tr = o.tr if (lEv == 'detail') pop(d);
if (lEv == 'deleted') deleted(d);
})
});