update Table
update Table
This commit is contained in:
parent
9f853e3ec8
commit
97edb2eb3b
3 changed files with 22 additions and 7 deletions
|
@ -45,13 +45,13 @@
|
||||||
`${this.prefixCls}-row`,
|
`${this.prefixCls}-row`,
|
||||||
this.rowClsName(_index),
|
this.rowClsName(_index),
|
||||||
{
|
{
|
||||||
[`${this.prefixCls}-row-highlight`]: this.objData[_index]._isHighlight,
|
[`${this.prefixCls}-row-highlight`]: this.objData[_index] && this.objData[_index]._isHighlight,
|
||||||
[`${this.prefixCls}-row-hover`]: this.objData[_index]._isHover
|
[`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
rowChecked (_index) {
|
rowChecked (_index) {
|
||||||
return this.objData[_index]._isChecked;
|
return this.objData[_index] && this.objData[_index]._isChecked;
|
||||||
},
|
},
|
||||||
setCellWidth (column, index) {
|
setCellWidth (column, index) {
|
||||||
return this.$parent.setCellWidth(column, index);
|
return this.$parent.setCellWidth(column, index);
|
||||||
|
|
|
@ -338,7 +338,7 @@
|
||||||
const key = this.cloneColumns[index].key;
|
const key = this.cloneColumns[index].key;
|
||||||
if (this.cloneColumns[index].sortable !== 'custom') { // custom is for remote sort
|
if (this.cloneColumns[index].sortable !== 'custom') { // custom is for remote sort
|
||||||
if (type === 'normal') {
|
if (type === 'normal') {
|
||||||
this.rebuildData = this.makeData();
|
this.rebuildData = this.makeDataWithFilter();
|
||||||
} else {
|
} else {
|
||||||
this.rebuildData = this.sortData(this.rebuildData, type, index);
|
this.rebuildData = this.sortData(this.rebuildData, type, index);
|
||||||
}
|
}
|
||||||
|
@ -415,6 +415,16 @@
|
||||||
if (sortType !== 'normal') data = this.sortData(data, sortType, sortIndex);
|
if (sortType !== 'normal') data = this.sortData(data, sortType, sortIndex);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
makeDataWithFilter () {
|
||||||
|
let data = this.makeData();
|
||||||
|
this.cloneColumns.forEach(col => data = this.filterData(data, col));
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
makeDataWithSortAndFilter () {
|
||||||
|
let data = this.makeDataWithSort();
|
||||||
|
this.cloneColumns.forEach(col => data = this.filterData(data, col));
|
||||||
|
return data;
|
||||||
|
},
|
||||||
makeObjData () {
|
makeObjData () {
|
||||||
let data = {};
|
let data = {};
|
||||||
this.data.forEach((row, index) => {
|
this.data.forEach((row, index) => {
|
||||||
|
@ -473,7 +483,7 @@
|
||||||
data: {
|
data: {
|
||||||
handler () {
|
handler () {
|
||||||
this.objData = this.makeObjData();
|
this.objData = this.makeObjData();
|
||||||
this.rebuildData = this.makeData();
|
this.rebuildData = this.makeDataWithSortAndFilter();
|
||||||
this.handleResize();
|
this.handleResize();
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
@ -481,6 +491,7 @@
|
||||||
columns: {
|
columns: {
|
||||||
handler () {
|
handler () {
|
||||||
this.cloneColumns = this.makeColumns();
|
this.cloneColumns = this.makeColumns();
|
||||||
|
this.rebuildData = this.makeDataWithSortAndFilter();
|
||||||
this.handleResize();
|
this.handleResize();
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<!--<div slot="footer">表格标题</div>-->
|
<!--<div slot="footer">表格标题</div>-->
|
||||||
</i-table>
|
</i-table>
|
||||||
<br>
|
<br>
|
||||||
|
<i-button @click="showChildren">显示子节点</i-button>
|
||||||
<!--<i-table size="small" border stripe :columns="columns" :data="data"></i-table>-->
|
<!--<i-table size="small" border stripe :columns="columns" :data="data"></i-table>-->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -219,6 +220,9 @@
|
||||||
},
|
},
|
||||||
sortChange (data) {
|
sortChange (data) {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
},
|
||||||
|
showChildren () {
|
||||||
|
console.log(this.$children)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ready () {
|
ready () {
|
||||||
|
@ -233,8 +237,8 @@
|
||||||
// address: '北京市东城区2',
|
// address: '北京市东城区2',
|
||||||
// edit: false
|
// edit: false
|
||||||
// });
|
// });
|
||||||
// this.data.splice(0, 1)
|
// this.data.splice(0, 1);
|
||||||
// this.columns.splice(2,1)
|
this.columns.splice(2,1)
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue