layui table 渲染二維數組
-------------------|------------------------------
版本:layui 2 | 瀏覽器:渲染代碼如下
var table = layui.table;
//第一個實例
table.render({
elem: '#factory'
,height: 312
,url: "{:url('admin/factory/index')}"
,method:'post'
,page: true //開啓分頁
,cols: [[ //表頭
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
,{field: 'supplier.id', title: '廠家', width:100}
,{field: 'name', title: '部門', width:80}
,{field: 'create_time', title: '創建時間', width:180, }
,{field: 'wealth', title: '財富', width: 135}
]]
});
});
數據格式如下截圖
渲染結果如下截圖
廠家那一列是二維數組,我如何才能渲染出廠家名字
解決辦法用這個 templet 終於解決,謝天謝地。阿彌陀佛
{field: 'supplier', title: '廠家', width:100,templet: '<div>{{d.supplier.supplier}}</div>' }