layui按條件隱藏表格列
阿新 • • 發佈:2018-12-18
直接上程式碼:
layui.use(['table','form','laypage'], function() {
var table = layui.table
,form = layui.form
,laypage = layui.laypage;
layer.load(0);
setTimeout(function() {
table.render({
id:"item",//用作於隱藏列名為item的列
elem: '#QD',
url:path+'test.do',
cols: [[ //表頭
{ field: 'quoted_price',title: '價格1',width: 150,align: 'left'},
{field: 'quoted_price2',title: '價格2',width: 150,align: 'left'}
]]
,where: {"page":page,"limit":limit}
,done: function(res, curr, count){
if(test== 0){//此處test為你的條件值
$("[data-field='quoted_price1']" ).css('display','none'); //關鍵程式碼
}
if(test2== 0){//此處test2為你的條件值
$("[data-field='quoted_price2']").css('display','none');//關鍵程式碼
}
}
laypage.render({//分頁
elem: 'page'
,count:count
,curr:page
,limit:limit
, jump: function(obj, first){
if(!first){
getRFQ_table(obj.curr,obj.limit);
}
}
});
}
});