提交 30b6aeaa 编写于 作者: A afc163

rowSelection getCheckboxProps, defaultValue should be defaultChecked

上级 3baeaeb0
......@@ -43,7 +43,7 @@ const data = [{
const rowSelection = {
getCheckboxProps: function(record) {
return {
defaultValue: record.name === '李大嘴', // 配置默认勾选的列
defaultChecked: record.name === '李大嘴', // 配置默认勾选的列
disabled: record.name === '胡彦祖' // 配置无法勾选的列
};
},
......
......@@ -44,7 +44,7 @@ const rowSelection = {
type: 'radio',
getCheckboxProps: function(record) {
return {
defaultValue: record.name === '李大嘴', // 配置默认勾选的列
defaultChecked: record.name === '李大嘴', // 配置默认勾选的列
disabled: record.name === '胡彦祖' // 配置无法勾选的列
};
},
......
# 单选
- order: 3
第一列是联动的单选框。
---
````jsx
import { Table } from 'antd';
const columns = [{
title: '姓名',
dataIndex: 'name',
render: function(text) {
return <a href="javascript:;">{text}</a>;
}
}, {
title: '年龄',
dataIndex: 'age'
}, {
title: '住址',
dataIndex: 'address'
}];
const data = [{
key: '1',
name: '胡彦斌',
age: 32,
address: '西湖区湖底公园1号'
}, {
key: '2',
name: '胡彦祖',
age: 42,
address: '西湖区湖底公园1号'
}, {
key: '3',
name: '李大嘴',
age: 32,
address: '西湖区湖底公园1号'
}];
// 通过 rowSelection 对象表明需要行选择
const rowSelection = {
type: 'radio',
onSelect: function(record, selected, selectedRows) {
console.log(record, selected, selectedRows);
},
onSelectAll: function(selected, selectedRows) {
console.log(selected, selectedRows);
}
};
ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
, document.getElementById('components-table-demo-row-selection-radio'));
````
......@@ -2,7 +2,7 @@
- order: 1
第一列是联动的选择框。
第一列是联动的选择框,rowSelection 中配置 `type="radio"` 可设为单选
---
......
......@@ -84,7 +84,7 @@ let AntTable = React.createClass({
let data = this.getCurrentPageData();
data.filter((item) => {
if (this.props.rowSelection.getCheckboxProps) {
return this.props.rowSelection.getCheckboxProps(item).defaultValue;
return this.props.rowSelection.getCheckboxProps(item).defaultChecked;
}
return true;
}).map((record, rowIndex) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册