feat:单选关联行样式改变
This commit is contained in:
parent
ac2b683cd3
commit
7b515fb57d
|
@ -101,6 +101,16 @@ function singleSelect(Table, Radio) {
|
|||
onRowClick && onRowClick(record, index, event);
|
||||
};
|
||||
|
||||
_this.getRowClassName = function (record, index, event) {
|
||||
var selectedRowIndex = _this.state.selectedRowIndex;
|
||||
|
||||
if (index === selectedRowIndex) {
|
||||
return 'selected';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
data: (0, _util.ObjectAssign)(props.data),
|
||||
selectedRowIndex: props.selectedRowIndex
|
||||
|
@ -140,7 +150,9 @@ function singleSelect(Table, Radio) {
|
|||
return _react2["default"].createElement(Table, _extends({}, this.props, {
|
||||
columns: this.getDefaultColumns(columns),
|
||||
data: data,
|
||||
onRowClick: this.onRowClick }));
|
||||
onRowClick: this.onRowClick,
|
||||
rowClassName: this.getRowClassName
|
||||
}));
|
||||
};
|
||||
|
||||
return SingleSelect;
|
||||
|
|
|
@ -55,6 +55,7 @@ class Demo12 extends Component {
|
|||
};
|
||||
return (
|
||||
<MultiSelectTable
|
||||
bordered
|
||||
columns={columns}
|
||||
data={data}
|
||||
// multiSelectConfig={multiObj} //可以自定义 Checkbox 属性
|
||||
|
|
|
@ -63,13 +63,6 @@ class Demo1302 extends Component {
|
|||
columns={columns}
|
||||
data={data}
|
||||
selectedRowIndex={selectedRowIndex}
|
||||
rowClassName={(record,index,indent)=>{
|
||||
if (index === selectedRowIndex) {
|
||||
return 'selected';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}}
|
||||
getSelectedDataFunc={this.getSelectedDataFunc}
|
||||
/>
|
||||
);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -96,6 +96,15 @@ export default function singleSelect(Table, Radio) {
|
|||
onRowClick && onRowClick(record,index,event);
|
||||
}
|
||||
|
||||
getRowClassName = (record,index,event) =>{
|
||||
let { selectedRowIndex } = this.state;
|
||||
if (index === selectedRowIndex) {
|
||||
return 'selected';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {columns} = this.props;
|
||||
const {data} = this.state;
|
||||
|
@ -103,7 +112,9 @@ export default function singleSelect(Table, Radio) {
|
|||
{...this.props}
|
||||
columns={this.getDefaultColumns(columns)}
|
||||
data={data}
|
||||
onRowClick={this.onRowClick}/>
|
||||
onRowClick={this.onRowClick}
|
||||
rowClassName={this.getRowClassName}
|
||||
/>
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue