需求:如果是新建的單據,就不允許進行勾選;如果打開之前建立的舊單,就可以進行勾選。
假設前面增加的選擇項的部分是
{ field: 'index1', checkbox: true, fixed: true, },
我們需要在done事件中進行判斷
, done: function (res, curr, count) { if ($("#isNew").val() == "1") { $(".layui-table-box").find("[data-field='index1']").css("display", "none"); } else { $(".layui-table-box").find("[data-field='index1']").removeAttr("display"); } }
我們也可以在下面的事件中對數據進行一些重新處理,比如:一個表單的Head和item同時抓取,Head單獨賦值,Item放到table中。
,parseData: function (res) { //將原始數據解析成 table 組件所規定的數據 var pohead = res.head; $("#txtPONo").html(pohead.id); ...... return { "code": "", //解析接口狀態 "msg": "", //解析提示文本 "count": res.items.total, //解析數據長度 "data": res.items //解析數據列表 }; }