add an example of sort data by table (#1236)
This commit is contained in:
parent
10031547ec
commit
f79d0febb1
|
@ -24,8 +24,9 @@
|
||||||
border
|
border
|
||||||
fit
|
fit
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
style="width: 100%;">
|
style="width: 100%;"
|
||||||
<el-table-column :label="$t('table.id')" align="center" width="65">
|
@sort-change="sortChange">
|
||||||
|
<el-table-column :label="$t('table.id')" prop="id" sortable="custom" align="center" width="65">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ scope.row.id }}</span>
|
<span>{{ scope.row.id }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -233,6 +234,20 @@ export default {
|
||||||
})
|
})
|
||||||
row.status = status
|
row.status = status
|
||||||
},
|
},
|
||||||
|
sortChange(data) {
|
||||||
|
const { prop, order } = data
|
||||||
|
if (prop === 'id') {
|
||||||
|
this.sortByID(order)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sortByID(order) {
|
||||||
|
if (order === 'ascending') {
|
||||||
|
this.listQuery.sort = '+id'
|
||||||
|
} else {
|
||||||
|
this.listQuery.sort = '-id'
|
||||||
|
}
|
||||||
|
this.handleFilter()
|
||||||
|
},
|
||||||
resetTemp() {
|
resetTemp() {
|
||||||
this.temp = {
|
this.temp = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
|
|
Loading…
Reference in New Issue