浏览代码

Table: `defaultExpandAll` works when expand column exists (#14935)

* Table: `defaultExpandAll` works when expand column exists

* fix
hetech 6 年之前
父节点
当前提交
b851242a5c
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 5 1
      packages/table/src/table-body.js
  2. 1 1
      test/unit/specs/table.spec.js

+ 5 - 1
packages/table/src/table-body.js

@@ -127,7 +127,7 @@ export default {
                   })
                 }
               </tr>);
-              if (this.store.isRowExpanded(row)) {
+              if (this.hasExpandColumn && this.store.isRowExpanded(row)) {
                 return [
                   tr,
                   <tr>
@@ -185,6 +185,10 @@ export default {
       return this.store.states.columns;
     },
 
+    hasExpandColumn() {
+      return this.columns.some(({ type }) => type === 'expand');
+    },
+
     firstDefaultColumnIndex() {
       for (let index = 0; index < this.columns.length; index++) {
         if (this.columns[index].type === 'default') {

+ 1 - 1
test/unit/specs/table.spec.js

@@ -949,7 +949,7 @@ describe('Table', () => {
                 <template slot-scope="props">
                   <div>{{props.row.name}}</div>
                 </template>
-            </el-table-column>
+              </el-table-column>
               <el-table-column prop="release" label="release" />
               <el-table-column prop="director" label="director" />
               <el-table-column prop="runtime" label="runtime" />