This commit is contained in:
梁灏 2017-07-18 15:03:27 +08:00
parent 096f2bfe9c
commit 1b737fdc83
2 changed files with 19 additions and 5 deletions

View file

@ -21,15 +21,16 @@
title: '姓名',
key: 'name',
width: 100,
fixed: 'left',
sortable: true,
renderHeader: (h, params) => {
return h('Tag', params.index)
}
// fixed: 'left',
// renderHeader: (h, params) => {
// return h('Tag', params.index)
// }
},
{
title: '年龄',
key: 'age',
sortable: true,
width: 100
},
{

View file

@ -10,7 +10,7 @@
<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>
<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>
<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>
@ -134,6 +134,19 @@
}
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) {
this.$parent.handleFilter(index);
},