layui按条件隐藏表格列的实例

我就废话不多说了,直接上关键代码吧!给大家做个参考

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); } } }); } });

以上这篇layui按条件隐藏表格列的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/5bfb4527d47f25562ca37752cf1d44ac.html