【问题标题】:Select All table rows (not only by pages) in vue-good-table Vue component在 vue-good-table Vue 组件中选择所有表格行(不仅是按页面)
【发布时间】:2020-09-04 09:35:38
【问题描述】:

我在 Laravel 项目中使用了一个名为 vue-good-table (https://xaksis.github.io/vue-good-table/) 的 Vue 组件。我只需要能够选择表中的所有记录,同时使用组件提供的分页。该组件提供此 SelectAll 功能,但问题是它仅适用于每个页面。您可以选择实际页面的所有行,但不能选择整个表格中的所有行,如下图所示:

selectAll example

是否可以使用 selectAll 按钮选择所有表格行或类似内容?

谢谢!

【问题讨论】:

    标签: laravel vue.js selectall vue-good-table


    【解决方案1】:

    添加到您的表 @on-select-all="selectAll" 所以它看起来像:

    <vue-good-table
        @on-select-all="selectAll"    
        :columns="columns"
        :rows="rows"
        :select-options="{ enabled: true }">
    </vue-good-table>
    

    并创建新方法

    selectAll(){
          this.row.forEach(item=>{
            if(item.vgtSelected){
              this.$set(item,'vgtSelected', false);
            }else{
              this.$set(item,'vgtSelected', true);
            }
          },this);
        }
    

    这应该可以解决您的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-14
      • 2019-03-31
      • 2020-07-11
      • 2021-07-22
      • 1970-01-01
      • 2020-08-30
      • 1970-01-01
      • 2019-03-16
      相关资源
      最近更新 更多