fixed #122
This commit is contained in:
parent
096f2bfe9c
commit
1b737fdc83
2 changed files with 19 additions and 5 deletions
|
@ -21,15 +21,16 @@
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
width: 100,
|
width: 100,
|
||||||
fixed: 'left',
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderHeader: (h, params) => {
|
// fixed: 'left',
|
||||||
return h('Tag', params.index)
|
// renderHeader: (h, params) => {
|
||||||
}
|
// return h('Tag', params.index)
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '年龄',
|
title: '年龄',
|
||||||
key: 'age',
|
key: 'age',
|
||||||
|
sortable: true,
|
||||||
width: 100
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<template v-if="column.type === 'expand'"></template>
|
<template v-if="column.type === 'expand'"></template>
|
||||||
<template v-else-if="column.type === 'selection'"><Checkbox :value="isSelectAll" @on-change="selectAll"></Checkbox></template>
|
<template v-else-if="column.type === 'selection'"><Checkbox :value="isSelectAll" @on-change="selectAll"></Checkbox></template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span v-if="!column.renderHeader">{{ column.title || '#' }}</span>
|
<span v-if="!column.renderHeader" @click="handleSortByHead(index)">{{ column.title || '#' }}</span>
|
||||||
<render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header>
|
<render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header>
|
||||||
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
|
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
|
||||||
<i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort(index, 'asc')"></i>
|
<i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort(index, 'asc')"></i>
|
||||||
|
@ -134,6 +134,19 @@
|
||||||
}
|
}
|
||||||
this.$parent.handleSort(index, type);
|
this.$parent.handleSort(index, type);
|
||||||
},
|
},
|
||||||
|
handleSortByHead (index) {
|
||||||
|
const column = this.columns[index];
|
||||||
|
if (column.sortable) {
|
||||||
|
const type = column._sortType;
|
||||||
|
if (type === 'normal') {
|
||||||
|
this.handleSort(index, 'asc');
|
||||||
|
} else if (type === 'asc') {
|
||||||
|
this.handleSort(index, 'desc');
|
||||||
|
} else {
|
||||||
|
this.handleSort(index, 'normal');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
handleFilter (index) {
|
handleFilter (index) {
|
||||||
this.$parent.handleFilter(index);
|
this.$parent.handleFilter(index);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue