Bootstrap如何隐藏table中的某一列

来源:互联网 发布:手机淘宝怎么注销账号 编辑:程序博客网 时间:2024/05/22 09:44

Bootstrap如何隐藏table中的某一列

一、
利用bootstrapTable来设置要隐藏和显示的列

$(function () {//初始化table  LoadingDataListOrderRealItems();//隐藏列  $('#tableOrderRealItems').bootstrapTable('showColumn', 'ShopName');  $('#tableOrderRealItems').bootstrapTable('hideColumn', 'GoodsId');  $('#tableOrderRealItems').bootstrapTable('hideColumn', 'OrderItemId');  $('#tableOrderRealItems').bootstrapTable('hideColumn', 'ShopName');        $('#tableOrderRealItems').bootstrapTable('hideColumn', 'SellerName');}); 

二、
也可以直接使用hidden属性来设置

columns: [{      field: 'OrderId',      title: '#',      align: 'center',    }, {      field: 'OrderItemId',      title: 'OrderItemId',      align: 'left',      hidden:true,    }, {      field: 'GoodsId',      title: 'GoodsId',      align: 'left',      hidden:true,    }, {      field: 'OrderCode',      title: '订单编号',      align: 'left',    }, {

这些方法是为了有的时候,表格需要有这么几列数据的存储,以供程序员使用,而不需要被展示出来,这时就需要将相应的列隐藏。