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中的方法,我这里是这样写的,具体判断还要根据实际情况