Layui動態表格
??????搜索ID:
搜索
????????layui.use('table',?function(){
var?table?=?layui.table;
??????????table.render({
????????????elem:?'#demo'
????????????,url:'index.php/Index/api'
????????????,page:?true
????????????,toolbar:true
????????????,totalRow:true
????????????,cols:?\[\[?
??????????????{field:?'id',?title:?'ID',?sort:?true,?rowspan:?2,?totalRow:?true}
??????????????,{field:?'username',?title:?'用戶名',?rowspan:?2}
??????????????,{field:?'sex',?title:?'性別',?sort:?true,?rowspan:?2,?templet:?'#sexTpl',?totalRow:?true}
??????????????,{align:?'center',?title:?'城市',colspan:3}?
??????????????,{field:?'sign',?title:?'簽名',?rowspan:?2}
??????????????,{field:?'experience',?title:?'積分',?sort:?true,?rowspan:?2,?totalRow:?true}
??????????????,{field:?'score',?title:?'評分',?sort:?true,?rowspan:?2}
??????????????,{field:?'classify',?title:?'財富',?rowspan:?2,?totalRow:?true}
??????????????,{field:?'wealth',?title:?'職業',??sort:?true,?rowspan:?2,?style:?'background-color:?#009688;?color:?#fff;',?totalRowText:?'合計'}
????????????\],
????????????\[
????????????{field:?'111',?title:?'省',align:?'center'}
????????????,{field:?'22',?title:?'市',align:?'center'}
????????????,{field:?'33',?title:?'區',align:?'center',}
??????????\]\]
??????????,?id:?'testReload'
??????????,done:?function?(res,curr,count)?{
??????$('th').css({'background-color':?'#009688','color':?'#fff',?'border':'1px?solid?#Fff'});//設置表頭背景和邊框
??????}
??????????});
var?$?=?layui.$,?active?=?{
????????????reload:?function?()?{
var?demoReload?=?$('#demoReload');
//執行重載
??????????????table.reload('testReload',?{
????????????????page:?{
??????????????????curr:?1//重新從第?1?頁開始
????????????????}
????????????????,?where:?{
??????????????????key:?{
????????????????????id:?demoReload.val()
??????????????????}
????????????????}
??????????????});
????????????}
??????????};
??????????$('.demoTable?.layui-btn').on('click',?function?()?{
var?type?=?$(this).data('type');
????????????active\[type\]???active\[type\].call(this)?:?'';
??????????});
????????});
??????????{{#??if(d.sex?===?0){?}}
{{?d.sex?}}
??????????{{#??}?else?{?}}
????????????{{?d.sex?}}
??????????{{#??}?}}
