mirror of https://github.com/ElemeFE/element
Table: not emit triggers sort-change during initialization (#14625)
parent
b9c63eecf9
commit
1967cd2b9e
|
@ -210,7 +210,8 @@ export default {
|
|||
|
||||
mounted() {
|
||||
const { prop, order } = this.defaultSort;
|
||||
this.store.commit('sort', { prop, order });
|
||||
const init = true;
|
||||
this.store.commit('sort', { prop, order, init });
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
|
|
|
@ -259,7 +259,7 @@ TableStore.prototype.mutations = {
|
|||
changeSortCondition(states, options) {
|
||||
states.data = sortData((states.filteredData || states._data || []), states);
|
||||
|
||||
if (!options || !options.silent) {
|
||||
if (!options || !(options.silent || options.init)) {
|
||||
this.table.$emit('sort-change', {
|
||||
column: this.states.sortingColumn,
|
||||
prop: this.states.sortProp,
|
||||
|
@ -271,7 +271,7 @@ TableStore.prototype.mutations = {
|
|||
},
|
||||
|
||||
sort(states, options) {
|
||||
const { prop, order } = options;
|
||||
const { prop, order, init } = options;
|
||||
if (prop) {
|
||||
states.sortProp = prop;
|
||||
states.sortOrder = order || 'ascending';
|
||||
|
@ -286,7 +286,9 @@ TableStore.prototype.mutations = {
|
|||
}
|
||||
|
||||
if (states.sortingColumn) {
|
||||
this.commit('changeSortCondition');
|
||||
this.commit('changeSortCondition', {
|
||||
init: init
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue