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属性对列进行显示与隐藏


基础教程推荐
猜你喜欢
- JSONObject与JSONArray使用方法解析 2024-02-07
- clientX,pageX,offsetX,x,layerX,screenX,offsetLeft区别分析 2024-01-08
- Django操作cookie的实现 2024-04-15
- Loaders.css免费开源加载动画框架介绍 2025-01-23
- Bootstrap学习笔记之css组件(3) 2024-01-22
- html5视频如何嵌入到网页(视频代码) 2025-01-22
- js判断一个对象是否在一个对象数组中(场景分析) 2022-10-21
- 创建Vue3.0需要安装哪些脚手架 2025-01-16
- webpack学习笔记一:安装webpack、webpack-dev-server、内存加载js和html文件、loader处理非js文件 2023-10-29
- 纯css实现漂亮又健壮的tooltip的方法 2024-01-23