Skip to content

Commit

Permalink
call sortChange on th click
Browse files Browse the repository at this point in the history
  • Loading branch information
timefordroids committed Oct 19, 2021
1 parent 148029a commit 09552d7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/style/ve-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
height: 16px;
margin-left: 5px;
color: @ve-table-sort-icon-default-color;
cursor: pointer;
.ve-table-sort-icon {
position: absolute;
display: block;
Expand Down Expand Up @@ -254,6 +253,10 @@
left: 5px;
}
}

.ve-table-sortable-column {
cursor: pointer;
}
}
}
}
Expand Down
21 changes: 18 additions & 3 deletions packages/ve-table/src/header/header-th.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ export default {
}
}

return result;
},
// is sortable column
isSortableCloumn() {
let result = false;

const { sortColumns, groupColumnItem } = this;
const currentField = groupColumnItem.field;

if (Object.keys(sortColumns).includes(currentField)) {
result = true;
}

return result;
},
},
Expand All @@ -155,6 +168,7 @@ export default {
[clsName("first-right-fixed-column")]:
this.isfirstRightFixedColumn,
[clsName("last-column")]: this.isLastCloumn,
[clsName("sortable-column")]: this.isSortableCloumn,
};

const { cellStyleOption, groupColumnItem, rowIndex } = this;
Expand Down Expand Up @@ -301,9 +315,6 @@ export default {

const props = {
class: clsName("sort"),
on: {
click: () => this.sortChange(),
},
};

result = (
Expand Down Expand Up @@ -428,6 +439,10 @@ export default {
const events = {
click: (e) => {
this.cellClick(e, click);

if (this.isSortableCloumn) {
this.sortChange();
}
},
dblclick: (e) => {
this.cellDblclick(e, dblclick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ exports[`veTable header paging render multiple field paging 1`] = `
<thead class="ve-table-fixed-header ve-table-header">
<tr class="ve-table-header-tr">
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
<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>
<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>
<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>
<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>
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
</tr>
Expand Down Expand Up @@ -84,8 +84,8 @@ exports[`veTable header paging render single field paging 1`] = `
<thead class="ve-table-fixed-header ve-table-header">
<tr class="ve-table-header-tr">
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
<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>
<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>
<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>
<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>
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
</tr>
Expand Down

0 comments on commit 09552d7

Please sign in to comment.