1. 程式人生 > >layui框架學習記錄

layui框架學習記錄

自定義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); }) });