Commit d9d1dbbd5a629afa50c2dcfb86180e23ed30e115

Authored by 梁灏
1 parent fc3e16cf

Table Column add indexMethod

Showing 2 changed files with 11 additions and 10 deletions   Show diff stats
examples/routers/table.vue
1 <template> 1 <template>
2 <div> 2 <div>
3 - <Table border ref="selection" :columns="columns4" :data="data1"></Table>  
4 - <br><br>  
5 - <Button @click="handleSelectAll(true)">Set all selected</Button>  
6 - <Button @click="handleSelectAll(false)">Cancel all selected</Button> 3 + <Table highlight-row ref="currentRowTable" :columns="columns3" :data="data1"></Table>
  4 + <Button @click="handleClearCurrentRow">Clear</Button>
7 </div> 5 </div>
8 </template> 6 </template>
9 <script> 7 <script>
10 export default { 8 export default {
11 data () { 9 data () {
12 return { 10 return {
13 - columns4: [ 11 + columns3: [
14 { 12 {
15 - type: 'selection', 13 + type: 'index',
16 width: 60, 14 width: 60,
17 - align: 'center' 15 + align: 'center',
  16 + indexMethod (row) {
  17 + return row._index;
  18 + }
18 }, 19 },
19 { 20 {
20 title: 'Name', 21 title: 'Name',
@@ -58,8 +59,8 @@ @@ -58,8 +59,8 @@
58 } 59 }
59 }, 60 },
60 methods: { 61 methods: {
61 - handleSelectAll (status) {  
62 - this.$refs.selection.selectAll(status); 62 + handleClearCurrentRow () {
  63 + this.$refs.currentRowTable.clearCurrentRow();
63 } 64 }
64 } 65 }
65 } 66 }
src/components/table/cell.vue
1 <template> 1 <template>
2 <div :class="classes" ref="cell"> 2 <div :class="classes" ref="cell">
3 - <template v-if="renderType === 'index'"><span>{{naturalIndex + 1}}</span></template> 3 + <template v-if="renderType === 'index'"><span>{{ column.indexMethod ? column.indexMethod(row) : (naturalIndex + 1) }}</span></template>
4 <template v-if="renderType === 'selection'"> 4 <template v-if="renderType === 'selection'">
5 <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> 5 <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
6 </template> 6 </template>