Skip to content

Commit c228013

Browse files
committed
add sort to table
Signed-off-by: zhangtianli2006 <49156174+zhangtianli2006@users.noreply.github.com>
1 parent 619bd60 commit c228013

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/components/lib/AjaxTable.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<div class="ajax-table">
3-
<el-table v-loading="loading" :data="tableData">
3+
<el-table
4+
v-loading="loading"
5+
:data="tableData"
6+
:default-sort="default_sort"
7+
>
48
<el-table-column
59
v-for="item in columns"
610
:key="item"
@@ -9,6 +13,7 @@
913
:width="item.width"
1014
:align="item.align"
1115
:header-align="item.headerAlign"
16+
:sortable="item.sortable"
1217
/>
1318
</el-table>
1419
<el-pagination
@@ -87,6 +92,9 @@ export default {
8792
process: {
8893
type: Function,
8994
default: x => x
95+
},
96+
default_sort: {
97+
9098
}
9199
},
92100
};

src/components/problem/list.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
:limit="limit"
4747
:total="data_count"
4848
:process="process"
49+
:default_sort="{prop: 'pid', order: 'ascending'}"
4950
/>
5051
</el-card>
5152
</div>
@@ -69,19 +70,23 @@ export default {
6970
name: 'score',
7071
label: 'Status',
7172
width: '120',
72-
align: 'center'
73+
align: 'center',
74+
sortable: true
7375
}, {
7476
name: 'pid',
7577
label: 'Problem ID',
7678
width: '120',
77-
align: 'center'
79+
align: 'center',
80+
sortable: true
7881
}, {
7982
name: 'title',
80-
label: 'Title'
83+
label: 'Title',
84+
sortable: false
8185
}, {
8286
name: 'tag',
8387
width: '400',
8488
align: 'right',
89+
sortable: false
8590
}],
8691
data_count: 10
8792
};

0 commit comments

Comments
 (0)