diff --git a/components/table/demo/row-selection-radio-props.md b/components/table/demo/row-selection-radio-props.md index bcfbdc5069..bdb159529a 100644 --- a/components/table/demo/row-selection-radio-props.md +++ b/components/table/demo/row-selection-radio-props.md @@ -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( +function rowKey(record) { + return record.id; +} + +ReactDOM.render(
, document.getElementById('components-table-demo-row-selection-radio-props')); ```` diff --git a/components/table/index.jsx b/components/table/index.jsx index 2dce32bf3b..5f58d0d429 100644 --- a/components/table/index.jsx +++ b/components/table/index.jsx @@ -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 ; + value={rowIndex} checked={checked}/>; }, renderSelectionCheckBox(value, record, index) {