Table data support to set cell className

Table data support to set cell className
This commit is contained in:
梁灏 2017-01-10 18:36:13 +08:00
parent f9f1865ca5
commit c211f71778
3 changed files with 39 additions and 10 deletions

View file

@ -1,9 +1,14 @@
export default {
methods: {
alignCls (column, type) {
alignCls (column, type, row = {}) {
let cellClassName = '';
if (row.cellClassName && column.key && row.cellClassName[column.key]) {
cellClassName = row.cellClassName[column.key];
}
return [
{
[`${column.className}`]: column.className && type === 'body',
[`${cellClassName}`]: cellClassName, // cell className
[`${column.className}`]: column.className && type === 'body', // column className
[`${this.prefixCls}-column-${column.align}`]: column.align,
[`${this.prefixCls}-hidden`]: (this.fixed === 'left' && column.fixed !== 'left') || (this.fixed === 'right' && column.fixed !== 'right') || (!this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right'))
}

View file

@ -11,7 +11,7 @@
@mouseleave.stop="handleMouseOut(row._index)"
@click.stop="clickCurrentRow(row._index)"
@dblclick.stop="dblclickCurrentRow(row._index)">
<td v-for="column in columns" :class="alignCls(column, 'body')">
<td v-for="column in columns" :class="alignCls(column, 'body', row)">
<Cell
:fixed="fixed"
:prefix-cls="prefixCls"