elementUI type=“selection“多选框选中 删除 回显 赋值问题 回显数组改变选中状态未改变

业务需求:
点击查询弹列表框
在这里插入图片描述
勾选列表选项保存
在这里插入图片描述
可删除可重新查询列表添加
在这里插入图片描述
遇到的问题:删除之后查询列表selection回显问题
解决:@row-click配合:reserve-selection="true"使用

      <el-table
        ref="refPlanTable"
        :data="refPlanTableData"
        tooltip-effect="dark"
        :max-height="400"
        :height="400"
        :header-cell-style="{textAlign: 'center'}"
        :cell-style="{textAlign:'center'}"
        @selection-change="handleSelectionChangeRef"
        @row-click="handleRowClickRef"
        :row-key="getRowKey"
      >
        <el-table-column type="selection" width="55" fixed="left" :reserve-selection="true"></el-table-column>
        </el-table>

handleRowClickRef(row){ this.$refs.refPlanTable.toggleRowSelection(row); },
表格data赋值的地方添加
注意::reserve-selection="true"会记录保存上一次选中的状态,所以每次赋值前要先清空选中状态

          this.refPlanTableData=res.result;
          let string = this.multipleSelectionRef.map(item => item.identity);
          console.log(string);
          this.$nextTick(() => {
            this.refPlanTableData.forEach(item=>{
              this.$refs.refPlanTable&&this.$refs.refPlanTable.toggleRowSelection(item,false);
              if(string.includes(item.identity)){
                this.$refs.refPlanTable&&this.$refs.refPlanTable.toggleRowSelection(item,true);
              }
            })
          })

最近更新

  1. TCP协议是安全的吗?

    2024-06-06 06:18:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-06 06:18:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-06 06:18:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-06 06:18:02       18 阅读

热门阅读

  1. pytest中fixture异常处理

    2024-06-06 06:18:02       10 阅读
  2. Linux之检索文件内容

    2024-06-06 06:18:02       9 阅读
  3. TalkingData数据统计的力量

    2024-06-06 06:18:02       10 阅读
  4. 【WP|4】WordPress 简码(Shortcode)开发详解

    2024-06-06 06:18:02       11 阅读
  5. 408链表的创建和初始化

    2024-06-06 06:18:02       9 阅读
  6. 跨越障碍:解决复杂网页数据提取的挑战

    2024-06-06 06:18:02       10 阅读
  7. k8s_设置dns

    2024-06-06 06:18:02       10 阅读
  8. PMAT安装及使用(Bioinformatics工具-021)

    2024-06-06 06:18:02       8 阅读
  9. Leetcode-3169. Count Days Without Meetings 题解

    2024-06-06 06:18:02       8 阅读
  10. 函数也能当变量?Python一等函数让你大开眼界!

    2024-06-06 06:18:02       9 阅读