vue element ui实现隐藏列

vue element ui实现隐藏列

<el-table-column v-for="col in columnDefs" :key="col.prop" :label="col.label" align="center" 
                       :show-overflow-tooltip="col.showOverflowTooltip">
   <template slot-scope="{row}">
     <span>{{ row[col.prop] }}</span>
   </template>
</el-table-column>
<el-table-column align="center" width="160">
        <template slot="header">
          <span>操作</span>
          <el-popover
            ref="popover"
            placement="left-start"
            title="隐藏/显示列"
            width="150"
            trigger="click">
            <el-checkbox-group v-for="col in columns" :key="col.prop" v-model="col.isShow">
              <el-checkbox :label="col.label" :checked="col.isShow"></el-checkbox>
            </el-checkbox-group>
            <el-button type="text" size="mini" slot="reference"><i class="el-icon-more" style="transform:rotate(90deg)"></i></el-button>
          </el-popover>
        </template>
        <template slot-scope="{row}">
          <el-button type="text" @click="handleUpdate(row)">
            {{ $t('table.edit') }}
          </el-button>
          <el-button type="text" @click="handleRemove(row.idId)">
            {{ $t('table.delete') }}
          </el-button>
        </template>
      </el-table-column>
computed: {
    columnDefs() {
      return this.columns.filter(item => item.isShow)
    }
  },
data() {
	return {
		columns: [
        { prop: 'idId',label: this.$t('bizid.idId'), isShow: true, width: 'auto', showOverflowTooltip: true },
        { prop: 'idName',label: this.$t('bizid.idName'), isShow: true, width: 'auto', showOverflowTooltip: true },
        { prop: 'idLength',label: this.$t('bizid.idLength'), isShow: true, width: 'auto'},
        { prop: 'idValue',label: this.$t('bizid.idValue'), isShow: true, width: 'auto' },
        { prop: 'isGlobal',label: this.$t('bizid.isGlobal'), isShow: true, width: 'auto' },
        { prop: 'idPrefix',label: this.$t('bizid.idPrefix'), isShow: true, width: 'auto' },
        { prop: 'idSuffix',label: this.$t('bizid.idSuffix'), isShow: true, width: 'auto' },
        { prop: 'idType',label: this.$t('bizid.idType'), isShow: true, width: 'auto' },
        { prop: 'organId',label: this.$t('bizid.organId'), isShow: true, width: 'auto' }
      ]
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值