Browse Source

Merge pull request #2473 from QingWei-Li/fix/table-column-key

Table: fix columnKey, fixed #2322
baiyaaaaa 8 years ago
parent
commit
8453db88e5
2 changed files with 8 additions and 6 deletions
  1. 3 3
      packages/table/src/table-column.js
  2. 5 3
      packages/table/src/table-store.js

+ 3 - 3
packages/table/src/table-column.js

@@ -182,8 +182,7 @@ export default {
   created() {
     this.customRender = this.$options.render;
     this.$options.render = h => h('div', this.$slots.default);
-
-    let columnId = this.columnId = this.columnKey || ((this.$parent.tableId || (this.$parent.columnId + '_')) + 'column_' + columnIdSeed++);
+    this.columnId = (this.$parent.tableId || (this.$parent.columnId + '_')) + 'column_' + columnIdSeed++;
 
     let parent = this.$parent;
     let owner = this.owner;
@@ -210,7 +209,8 @@ export default {
     let isColumnGroup = false;
 
     let column = getDefaultColumn(type, {
-      id: columnId,
+      id: this.columnId,
+      columnKey: this.columnKey,
       label: this.label,
       className: this.className,
       property: this.prop || this.property,

+ 5 - 3
packages/table/src/table-store.js

@@ -152,15 +152,17 @@ TableStore.prototype.mutations = {
     }
 
     const prop = column.property;
+    const filters = [];
+
     if (prop) {
       states.filters[column.id] = values;
+      filters[column.columnKey || column.id] = values;
     }
 
     let data = states._data;
-    const filters = states.filters;
 
-    Object.keys(filters).forEach((columnId) => {
-      const values = filters[columnId];
+    Object.keys(states.filters).forEach((columnId) => {
+      const values = states.filters[columnId];
       if (!values || values.length === 0) return;
       const column = getColumnById(this.states, columnId);
       if (column && column.filterMethod) {