update Table

update Table
This commit is contained in:
梁灏 2016-11-28 21:30:59 +08:00
parent 35ad37642d
commit 642299b9b8
5 changed files with 110 additions and 33 deletions

View file

@ -310,24 +310,26 @@
this.cloneColumns.forEach((col) => col._sortType = 'normal');
const key = this.cloneColumns[index].key;
if (type === 'asc') {
this.rebuildData.sort((a, b) => {
if (this.cloneColumns[index].sortMethod) {
return this.cloneColumns[index].sortMethod(a, b);
} else {
return a[key] > b[key];
}
});
} else if (type === 'desc') {
this.rebuildData.sort((a, b) => {
if (this.cloneColumns[index].sortMethod) {
return this.cloneColumns[index].sortMethod(a, b);
} else {
return a[key] < b[key];
}
});
} else if (type === 'normal') {
this.rebuildData = this.makeData();
if (this.cloneColumns[index].sortable !== 'custom') { // custom is for remote sort
if (type === 'asc') {
this.rebuildData.sort((a, b) => {
if (this.cloneColumns[index].sortMethod) {
return this.cloneColumns[index].sortMethod(a, b);
} else {
return a[key] > b[key];
}
});
} else if (type === 'desc') {
this.rebuildData.sort((a, b) => {
if (this.cloneColumns[index].sortMethod) {
return this.cloneColumns[index].sortMethod(a, b);
} else {
return a[key] < b[key];
}
});
} else if (type === 'normal') {
this.rebuildData = this.makeData();
}
}
this.cloneColumns[index]._sortType = type;