GridManager 表格管理組件盟戏, 對(duì)列的隱藏與顯示的操作有兩種方式板祝。
1.初始化時(shí)指定列為隱藏或顯示狀態(tài)宫静。方式如下:
<table></table>
table.GM({
gridManagerName: 'test',
ajax_data: 'http://www.lovejavascript.com/learnLinkManager/getLearnLinkList',
columnData: [{
key: 'name',
// 指定不顯示該列
isShow: false,
text: 'username'
},{
key: 'type',
// 指定顯示該列
isShow: true,
text: 'type'
},{
key: 'info',
// 不指定該列的顯示狀態(tài), 默認(rèn)為true
text: 'info'
}]
});
2.渲染完成后扔字,對(duì)列進(jìn)行隱藏或顯示操作囊嘉。在已經(jīng)執(zhí)行過(guò)init的前提下,可通過(guò)如下方式對(duì)列進(jìn)行操作:
// 對(duì)第一列進(jìn)行顯示
GridManager.showTh('test', 'name');
// 對(duì)第二列進(jìn)行隱藏
GridManager.hideTh('test', 'type');
// 批量操作 -> 隱藏第二和第三列
GridManager.hideTh('test', ['type', 'info']);
// 批量操作 -> 顯示全部列
GridManager.showTh('test', ['name', 'type', 'info']);