layui 数据表格 根据条件 隐藏列

table.render({
            elem: '#idTest' //指定原始表格元素选择器(推荐id选择器)
         
            , url: '/Plan/GetAjaxUserPageList'//数据接口地址
            , height: 500 //容器高度
            , cols: [[{ type: 'checkbox', fixed: 'left' },
                { field: 'PId', title: "父id", align: 'center', hide: "true" },
                { field: 'PlanId', sort: true, fixed: true, title: "方案编号", align: 'center', width: 80 },

                { field: 'CorpName', title: "公司名称", align: 'center', },
                { field: 'PlanName', title: "方案名称", align: 'center', },

                { field: 'Type', title: "类型", align: 'center', },
                //{ field: 'IdType', title: "证件类型", align: 'center', },
                //{ field: 'Phone', title: "手机号", align: 'center', },

                //{
                //    field: 'Sex', title: '性别', align: 'center',
                //    templet: function (row) {
                //        if (row.Sex == "1") {
                //            return "男";
                //        } else if (row.Sex == "0") {
                //            return "女";
                //        }
                //        else {
                //            return "";
                //        }

                //    }

                //},
                { field: 'IsOpen', title: "投保权限", width: 200, align: 'center', templet: switchTpl },
                { fixed: 'right', title: "操作", width: 300, align: 'center', toolbar: '#barDemo' }
            ]], //设置表头
            page: true,//开启分页
            limit: 10,
            limits: [5, 10, 15, 20],
            done: function (res, curr, count) {
                //如果是异步请求数据方式,res即为你接口返回的信息。
                //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);
               
                if (res.data[0].PId !=2  ) {
                    $("[data-field='CorpName']").css('display', 'none'); //关键代码
                }

               
            }
        });

主要就是done中的方法,我这里是这样写的,具体判断还要根据实际情况

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值