This commit is contained in:
梁灏 2017-07-14 14:52:54 +08:00
parent 82d90c4f8f
commit 68b308ee83
4 changed files with 138 additions and 60 deletions

View file

@ -7,6 +7,7 @@
<template v-for="(row, index) in data">
<table-tr
:row="row"
:key="row._rowKey"
:prefix-cls="prefixCls"
@mouseenter.native.stop="handleMouseIn(row._index)"
@mouseleave.native.stop="handleMouseOut(row._index)"
@ -17,7 +18,7 @@
:fixed="fixed"
:prefix-cls="prefixCls"
:row="row"
:key="row"
:key="column._columnKey"
:column="column"
:natural-index="index"
:index="row._index"
@ -29,7 +30,7 @@
</table-tr>
<tr v-if="rowExpanded(row._index)">
<td :colspan="columns.length" :class="prefixCls + '-expanded-cell'">
<Expand :key="row" :row="row" :render="expandRender" :index="row._index"></Expand>
<Expand :key="row._rowKey" :row="row" :render="expandRender" :index="row._index"></Expand>
</td>
</tr>
</template>

View file

@ -26,7 +26,7 @@
<div slot="content" :class="[prefixCls + '-filter-list']" v-if="column._filterMultiple">
<div :class="[prefixCls + '-filter-list-item']">
<checkbox-group v-model="column._filterChecked">
<checkbox v-for="item in column.filters" :key="item" :label="item.value">{{ item.label }}</checkbox>
<checkbox v-for="item in column.filters" :key="column._columnKey" :label="item.value">{{ item.label }}</checkbox>
</checkbox-group>
</div>
<div :class="[prefixCls + '-filter-footer']">

View file

@ -44,7 +44,7 @@
:styleObject="fixedTableStyle"
:columns="leftFixedColumns"
:obj-data="objData"
:columns-width.sync="columnsWidth"
:columns-width="columnsWidth"
:data="rebuildData"></table-head>
</div>
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody">
@ -95,6 +95,9 @@
const prefixCls = 'ivu-table';
let rowKey = 1;
let columnKey = 1;
export default {
name: 'Table',
mixins: [ Locale ],
@ -562,7 +565,10 @@
},
makeData () {
let data = deepCopy(this.data);
data.forEach((row, index) => row._index = index);
data.forEach((row, index) => {
row._index = index;
row._rowKey = rowKey++;
});
return data;
},
makeDataWithSort () {
@ -629,6 +635,7 @@
columns.forEach((column, index) => {
column._index = index;
column._columnKey = columnKey++;
column._width = column.width ? column.width : ''; // update in handleResize()
column._sortType = 'normal';
column._filterVisible = false;