Layui數(shù)據(jù)表格 前后端json數(shù)據(jù)接收的方法
更新時間:2019年09月19日 15:22:04 作者:鄭清
今天小編就為大家分享一篇Layui數(shù)據(jù)表格 前后端json數(shù)據(jù)接收的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
先上效果圖:
前端數(shù)據(jù)表格:
<div class="x-body"> <%-- 數(shù)據(jù)表格 --%> <table class="layui-table" lay-data="{ id:'test', url:'/menu/page', page:true, limits: [10,20,50], //每頁條數(shù)的選擇項,默認:[10,20,30,40,50,60,70,80,90] limit: 10, //每頁默認顯示的數(shù)量 method:'post' //提交方式 }" lay-filter="test"> <thead> <tr> <th lay-data="{field:'id', width:80, sort: true}">編號</th> <th lay-data="{field:'name'}">菜單名稱</th> <th lay-data="{field:'url', sort: true}">菜單路徑</th> <th lay-data="{field:'icon'}">菜單圖標</th> <th lay-data="{field:'parent'}">菜單</th> <th lay-data="{field:'children', sort: true}">子菜單</th> <th lay-data="{fixed: 'right', toolbar: '#barDemo', width:250, align:'center'}">操作</th> </tr> </thead> </table> </div> <%-- 這里可以放CRUD按鈕 --%> <script type="text/html" id="barDemo"> <a class="layui-btn layui-btn-xs" lay-event="detail">編輯</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">刪除</a> </script>
js代碼
$(function () { //注意:這里是數(shù)據(jù)表格的加載數(shù)據(jù),必須寫 layui.use(['table', 'layer', 'form'], function () { var table = layui.table; layer = layui.layer; form = layui.form; //CURD... }); });
后端需要返回的json數(shù)據(jù)格式:
我們可以自己抽一個工具類出來封裝成前端需要返回的json數(shù)據(jù)格式哦
public class PageUtil<T> { private int code=0; private String msg; private Long count; //總條數(shù) private List<T> data = new ArrayList(); //裝前臺當前頁的數(shù)據(jù) //getter/setter方法... }
以上這篇Layui數(shù)據(jù)表格 前后端json數(shù)據(jù)接收的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
JS格式化數(shù)字金額用逗號隔開保留兩位小數(shù)
JS格式化數(shù)字金額只留兩位小數(shù)。寫了個格式化函數(shù)??梢钥刂菩?shù)位數(shù),自動四舍五入,感興趣的朋友可以了解下2013-10-10超鏈接怎么正確調(diào)用javascript函數(shù)
本文介紹使用超鏈接調(diào)用javasript函數(shù)且不會影響GIF圖片動畫的方法,有遇到相同問題的小伙伴可以參考一下。2016-05-05淺談js圖片前端預覽之filereader和window.URL.createObjectURL
下面小編就為大家?guī)硪黄獪\談js圖片前端預覽之filereader和window.URL.createObjectURL。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-06