Table Column add indexMethod

This commit is contained in:
梁灏 2018-06-29 10:04:02 +08:00
parent fc3e16cf01
commit d9d1dbbd5a
2 changed files with 11 additions and 10 deletions

View file

@ -1,20 +1,21 @@
<template> <template>
<div> <div>
<Table border ref="selection" :columns="columns4" :data="data1"></Table> <Table highlight-row ref="currentRowTable" :columns="columns3" :data="data1"></Table>
<br><br> <Button @click="handleClearCurrentRow">Clear</Button>
<Button @click="handleSelectAll(true)">Set all selected</Button>
<Button @click="handleSelectAll(false)">Cancel all selected</Button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
columns4: [ columns3: [
{ {
type: 'selection', type: 'index',
width: 60, width: 60,
align: 'center' align: 'center',
indexMethod (row) {
return row._index;
}
}, },
{ {
title: 'Name', title: 'Name',
@ -58,8 +59,8 @@
} }
}, },
methods: { methods: {
handleSelectAll (status) { handleClearCurrentRow () {
this.$refs.selection.selectAll(status); this.$refs.currentRowTable.clearCurrentRow();
} }
} }
} }

View file

@ -1,6 +1,6 @@
<template> <template>
<div :class="classes" ref="cell"> <div :class="classes" ref="cell">
<template v-if="renderType === 'index'"><span>{{naturalIndex + 1}}</span></template> <template v-if="renderType === 'index'"><span>{{ column.indexMethod ? column.indexMethod(row) : (naturalIndex + 1) }}</span></template>
<template v-if="renderType === 'selection'"> <template v-if="renderType === 'selection'">
<Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
</template> </template>