Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 09552d7

Browse files
call sortChange on th click
1 parent 148029a commit 09552d7

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

‎packages/style/ve-table.less

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@
222222
height: 16px;
223223
margin-left: 5px;
224224
color: @ve-table-sort-icon-default-color;
225-
cursor: pointer;
226225
.ve-table-sort-icon {
227226
position: absolute;
228227
display: block;
@@ -254,6 +253,10 @@
254253
left: 5px;
255254
}
256255
}
256+
257+
.ve-table-sortable-column {
258+
cursor: pointer;
259+
}
257260
}
258261
}
259262
}

‎packages/ve-table/src/header/header-th.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ export default {
137137
}
138138
}
139139

140+
return result;
141+
},
142+
// is sortable column
143+
isSortableCloumn() {
144+
let result = false;
145+
146+
const { sortColumns, groupColumnItem } = this;
147+
const currentField = groupColumnItem.field;
148+
149+
if (Object.keys(sortColumns).includes(currentField)) {
150+
result = true;
151+
}
152+
140153
return result;
141154
},
142155
},
@@ -155,6 +168,7 @@ export default {
155168
[clsName("first-right-fixed-column")]:
156169
this.isfirstRightFixedColumn,
157170
[clsName("last-column")]: this.isLastCloumn,
171+
[clsName("sortable-column")]: this.isSortableCloumn,
158172
};
159173

160174
const { cellStyleOption, groupColumnItem, rowIndex } = this;
@@ -301,9 +315,6 @@ export default {
301315

302316
const props = {
303317
class: clsName("sort"),
304-
on: {
305-
click: () => this.sortChange(),
306-
},
307318
};
308319

309320
result = (
@@ -428,6 +439,10 @@ export default {
428439
const events = {
429440
click: (e) => {
430441
this.cellClick(e, click);
442+
443+
if (this.isSortableCloumn) {
444+
this.sortChange();
445+
}
431446
},
432447
dblclick: (e) => {
433448
this.cellDblclick(e, dblclick);

‎tests/unit/specs/__snapshots__/ve-table-header-paging.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ exports[`veTable header paging render multiple field paging 1`] = `
1414
<thead class="ve-table-fixed-header ve-table-header">
1515
<tr class="ve-table-header-tr">
1616
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
17-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
18-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
17+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
18+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
1919
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
2020
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
2121
</tr>
@@ -84,8 +84,8 @@ exports[`veTable header paging render single field paging 1`] = `
8484
<thead class="ve-table-fixed-header ve-table-header">
8585
<tr class="ve-table-header-tr">
8686
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
87-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
88-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
87+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
88+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
8989
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
9090
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
9191
</tr>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /