找回密码
 立即注册
首页 资源区 代码 vxe-table 如何实现分组列头折叠列功能

vxe-table 如何实现分组列头折叠列功能

梁宁 前天 15:00
实现 vxe-table 分组列头折叠列功能非常简单,只需改变列的 visible 就可以实现
https://vxetable.cn
1.gif

通过修改列的 visible 属性来精确控制列的显示隐藏
  1. <template>
  2.   
  3.     <vxe-table
  4.       border
  5.       height="400"
  6.       :data="tableData">
  7.       <vxe-column type="checkbox" width="60"></vxe-column>
  8.       <vxe-colgroup field="g1" title="分组1">
  9.         <template #header="{ column }">
  10.           <vxe-button mode="text" :icon="foldMaps.g1 ? 'vxe-icon-square-minus' : 'vxe-icon-square-plus'" @click="collapsable('g1')"></vxe-button>
  11.           {{ column.title }}
  12.         </template>
  13.         <vxe-column field="name" title="Name" width="200"></vxe-column>
  14.         <vxe-column field="role" title="Role" :visible="foldMaps.g1" width="200"></vxe-column>
  15.         <vxe-column field="sex" title="Sex" :visible="foldMaps.g1" width="200"></vxe-column>
  16.       </vxe-colgroup>
  17.       <vxe-colgroup field="g2" title="分组2">
  18.         <template #header="{ column }">
  19.           <vxe-button mode="text" :icon="foldMaps.g2 ? 'vxe-icon-square-minus' : 'vxe-icon-square-plus'" @click="collapsable('g2')"></vxe-button>
  20.           {{ column.title }}
  21.         </template>
  22.         <vxe-column field="age" title="Age" width="200"></vxe-column>
  23.         <vxe-column field="rate" title="Rate" :visible="foldMaps.g2" width="200"></vxe-column>
  24.         <vxe-column field="address" title="Address" :visible="foldMaps.g2" width="200"></vxe-column>
  25.       </vxe-colgroup>
  26.     </vxe-table>
  27.   
  28. </template>
复制代码
https://gitee.com/x-extends/vxe-table

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册