Commit ec182424 authored by lirilsu's avatar lirilsu Committed by 杨奕

Table: Add clear sort

parent 26a8c222
...@@ -150,14 +150,16 @@ TableStore.prototype.mutations = { ...@@ -150,14 +150,16 @@ TableStore.prototype.mutations = {
Vue.nextTick(() => this.table.updateScrollY()); Vue.nextTick(() => this.table.updateScrollY());
}, },
changeSortCondition(states) { changeSortCondition(states, options) {
states.data = sortData((states.filteredData || states._data || []), states); states.data = sortData((states.filteredData || states._data || []), states);
this.table.$emit('sort-change', { if (!options || !options.silent) {
column: this.states.sortingColumn, this.table.$emit('sort-change', {
prop: this.states.sortProp, column: this.states.sortingColumn,
order: this.states.sortOrder prop: this.states.sortProp,
}); order: this.states.sortOrder
});
}
Vue.nextTick(() => this.table.updateScrollY()); Vue.nextTick(() => this.table.updateScrollY());
}, },
...@@ -435,6 +437,20 @@ TableStore.prototype.clearFilter = function() { ...@@ -435,6 +437,20 @@ TableStore.prototype.clearFilter = function() {
this.table.$emit('filter-clear'); this.table.$emit('filter-clear');
}; };
TableStore.prototype.clearSort = function() {
const states = this.states;
if (!states.sortingColumn) return;
states.sortingColumn.order = null;
states.sortProp = null;
states.sortOrder = null;
this.commit('changeSortCondition', {
silent: true
});
this.table.$emit('sort-clear');
};
TableStore.prototype.updateAllSelected = function() { TableStore.prototype.updateAllSelected = function() {
const states = this.states; const states = this.states;
const { selection, rowKey, selectable, data } = states; const { selection, rowKey, selectable, data } = states;
......
...@@ -250,6 +250,10 @@ ...@@ -250,6 +250,10 @@
this.store.clearFilter(); this.store.clearFilter();
}, },
clearSort() {
this.store.clearSort();
},
handleMouseLeave() { handleMouseLeave() {
this.store.commit('setHoverRow', null); this.store.commit('setHoverRow', null);
if (this.hoverState) this.hoverState = null; if (this.hoverState) this.hoverState = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment