Table: fix wrong stripe style with expandable rows (#4873)

pull/4977/head
杨奕 2017-05-20 23:08:23 -07:00 committed by Cyril Su
parent b124944dd8
commit 5257b1ede8
3 changed files with 10 additions and 3 deletions

View File

@ -14,6 +14,7 @@ export default {
store: { store: {
required: true required: true
}, },
stripe: Boolean,
context: {}, context: {},
layout: { layout: {
required: true required: true
@ -52,7 +53,7 @@ export default {
on-contextmenu={ ($event) => this.handleContextMenu($event, row) } on-contextmenu={ ($event) => this.handleContextMenu($event, row) }
on-mouseenter={ _ => this.handleMouseEnter($index) } on-mouseenter={ _ => this.handleMouseEnter($index) }
on-mouseleave={ _ => this.handleMouseLeave() } on-mouseleave={ _ => this.handleMouseLeave() }
class={ ['el-table__row', this.getRowClass(row, $index)] }> class={ [this.getRowClass(row, $index)] }>
{ {
this._l(this.columns, (column, cellIndex) => this._l(this.columns, (column, cellIndex) =>
<td <td
@ -186,8 +187,11 @@ export default {
}, },
getRowClass(row, index) { getRowClass(row, index) {
const classes = []; const classes = ['el-table__row'];
if (this.stripe && index % 2 === 1) {
classes.push('el-table__row--striped');
}
const rowClassName = this.rowClassName; const rowClassName = this.rowClassName;
if (typeof rowClassName === 'string') { if (typeof rowClassName === 'string') {
classes.push(rowClassName); classes.push(rowClassName);

View File

@ -26,6 +26,7 @@
<table-body <table-body
:context="context" :context="context"
:store="store" :store="store"
:stripe="stripe"
:layout="layout" :layout="layout"
:row-class-name="rowClassName" :row-class-name="rowClassName"
:row-style="rowStyle" :row-style="rowStyle"
@ -69,6 +70,7 @@
<table-body <table-body
fixed="left" fixed="left"
:store="store" :store="store"
:stripe="stripe"
:layout="layout" :layout="layout"
:highlight="highlightCurrentRow" :highlight="highlightCurrentRow"
:row-class-name="rowClassName" :row-class-name="rowClassName"
@ -110,6 +112,7 @@
<table-body <table-body
fixed="right" fixed="right"
:store="store" :store="store"
:stripe="stripe"
:layout="layout" :layout="layout"
:row-class-name="rowClassName" :row-class-name="rowClassName"
:row-style="rowStyle" :row-style="rowStyle"

View File

@ -386,7 +386,7 @@
@modifier striped { @modifier striped {
& .el-table__body { & .el-table__body {
& tr:nth-child(2n) { & tr.el-table__row--striped {
td { td {
background: #FAFAFA; background: #FAFAFA;
background-clip: padding-box; background-clip: padding-box;