提交 d1c73231 编写于 作者: B Benjy Cui

fix: `rowKey` should work with Radio #697

上级 3ec39dcb
......@@ -23,17 +23,17 @@ const columns = [{
dataIndex: 'address'
}];
const data = [{
key: '1',
id: '1',
name: '胡彦斌',
age: 32,
address: '西湖区湖底公园1号'
}, {
key: '2',
id: '2',
name: '胡彦祖',
age: 42,
address: '西湖区湖底公园1号'
}, {
key: '3',
id: '3',
name: '李大嘴',
age: 32,
address: '西湖区湖底公园1号'
......@@ -56,6 +56,10 @@ const rowSelection = {
}
};
ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
function rowKey(record) {
return record.id;
}
ReactDOM.render(<Table rowSelection={rowSelection} rowKey={rowKey} columns={columns} dataSource={data} />
, document.getElementById('components-table-demo-row-selection-radio-props'));
````
......@@ -205,7 +205,7 @@ let AntTable = React.createClass({
selectedRowKeys = [key];
this.setState({
selectedRowKeys: selectedRowKeys,
radioIndex: record.key,
radioIndex: key,
selectionDirty: true
});
if (this.props.rowSelection.onSelect) {
......@@ -271,13 +271,13 @@ let AntTable = React.createClass({
}
let checked;
if (this.state.selectionDirty) {
checked = this.state.radioIndex === record.key;
checked = this.state.radioIndex === rowIndex;
} else {
checked = (this.state.radioIndex === record.key ||
checked = (this.state.radioIndex === rowIndex ||
this.getDefaultSelection().indexOf(rowIndex) >= 0);
}
return <Radio disabled={props.disabled} onChange={this.handleRadioSelect.bind(this, record, rowIndex)}
value={record.key} checked={checked}/>;
value={rowIndex} checked={checked}/>;
},
renderSelectionCheckBox(value, record, index) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册