Layuiバックグラウンドからtableへのデータのリモートロード
1183 ワード
例は次のとおりです.
```table url json ,
code:0 //
msg:"" //
count:1000 //
data:[] //
@RequestMapping("/list")
@ResponseBody
public Object list(){
Map map=new HashMap<>();
List list=employeeService.selectAll();
int count = employeeService.selectCount();
map.put(“code”, 0);
map.put(“msg”, “”);
map.put(“count”, count);
map.put(“data”, list);
return map;
}
layui.use('table', function(){
var table = layui.table;
table.render({
elem: '#demo'
,height: 312
,url:'employee/list'//データインタフェース
,page:true// ページを く
,cols:[//ヘッダ]
{field: 'id', title: 'ID', width:120, sort: true, fixed: 'left'}
,{field:'username',title:'ユーザー ',width:120}
,{field:'tel',title:' ',width:120,sort:true}
,{field:'email',title:'メールボックス',width:120}
,{field:'deptId',title:' ',width:120}
,{field:'inputtime',title:' ',width:120,sort:true}
,{field:'state',title:' ',width:120,sort:true}
]]
});
});