LayUI Table列的显示与隐藏可以通过CSS样式来控制,但是效果不是很满意。这里我通过修改列hide属性后重载表格来实现个别列的显示与隐藏。LayUI Table列的显示与隐藏可以通过CSS样式来控制,但是效果不是很满意。这里我通过修改列hide属性后重载表格来实现个别列的显示与隐藏。 1.单独定义表格形式: let cols1 = [ { type: 'numbers', title: '序号', width: 60, align: 'center' } , { field: 'MerchantNo', tit
1.单独定义表格形式:
let cols1 = [
{ type: 'numbers', title: '序号', width: 60, align: 'center' }
, { field: 'MerchantNo', title: '单位编号', width: 180, align: 'center' }
, { field: 'MerchantName', title: '单位名称', width: 180, align: 'center' }
, { field: 'Province', title: '省份', width: 120, align: 'center' }
, { field: 'Contacts', title: '联系人', width: 120, align: 'center' }
, { field: 'ContactPhp', title: '联系电话', width: 120, align: 'center' }
, { field: 'Fox', title: '传真', width: 100, align: 'center' }
, { field: 'EMail', title: '邮箱地址', width: 120, align: 'center' }
, { field: 'Address', title: '公司地址', width: 120, align: 'center' }
, { field: 'Synopsis', title: '公司简介', align: 'center' }
, { field: 'AdminCount', title: '允许账号数目', width: 100, align: 'center', hide: true }
, { field: 'Duetime', title: '有效期', width: 110, align: 'center', hide: true }
, { field: 'IsEnable', title: '状态', width: 100, align: 'center', templet: '#IsEnabledTpl' }
, { fixed: 'right', title: '操作', width: 125, align: 'center', toolbar: '#barOperation' }
];
2.根据需求修改列的属性:
var isReload = false;
if (res[0]['ShowOther'] == '0') {
if (!cols1[10].hide) {
isReload = true;
}
cols1[10].hide = true;
cols1[11].hide = true;
} else {
if (cols1[10].hide) {
isReload = true;
}
cols1[10].hide = false;
cols1[11].hide = false;
}
3.对表格重载:
if (isReload) {
insTb.reload({
cols: [cols1]
});
}
沃梦达教程
本文标题为:layui table使用hide属性对列进行显示与隐藏
基础教程推荐
猜你喜欢
- CSS3的几个标签速记(推荐) 2024-04-07
- 浅谈Vue2和Vue3的数据响应 2023-10-08
- 浅析canvas元素的html尺寸和css尺寸对元素视觉的影响 2024-04-26
- this[] 指的是什么内容 讨论 2023-11-30
- 关于文字内容过长,导致文本内容超出html 标签宽度的解决方法之自动换行 2023-10-28
- vue离线环境如何安装脚手架vue-cli 2025-01-19
- Ajax实现动态加载数据 2023-02-01
- JS前端广告拦截实现原理解析 2024-04-22
- 基于Vue制作组织架构树组件 2024-04-08
- js禁止页面刷新与后退的方法 2024-01-08
