提交 a707df52 编写于 作者: A afc163

Add filterMultiple in table column, close #442

上级 be42f568
......@@ -2,7 +2,7 @@
- order: 6
对某一列数据进行筛选,使用列的 `filter` 属性来指定筛选的列表
对某一列数据进行筛选,使用列的 `filter` 属性来指定需要筛选菜单的列,`onFilter` 用于筛选当前数据,`filterMultiple` 用于指定多选和单选
对某一列数据进行排序,通过指定列的 `sorter` 函数即可启动排序按钮。`sorter: function(a, b) { ... }`, a、b 为比较的两个列数据。
......@@ -38,6 +38,17 @@ const columns = [{
}, {
title: '地址',
dataIndex: 'address',
filters: [{
text: '南湖',
value: '南湖'
}, {
text: '西湖',
value: '西湖'
}],
filterMultiple: false,
onFilter: function(value, record) {
return record.address.indexOf(value) === 0;
},
sorter: function(a, b) {
return a.address.length - b.address.length;
}
......@@ -47,7 +58,7 @@ const data = [{
key: '1',
name: '胡斌',
age: 32,
address: '西湖区湖底公园1号'
address: '湖区湖底公园1号'
}, {
key: '2',
name: '胡彦祖',
......@@ -57,7 +68,7 @@ const data = [{
key: '3',
name: '李大嘴',
age: 32,
address: '西湖区湖底公园123号'
address: '湖区湖底公园123号'
}, {
key: '4',
name: '李秀莲大嘴哥',
......
......@@ -49,7 +49,12 @@ let FilterMenu = React.createClass({
},
render() {
let column = this.props.column;
let menus = <Menu multiple={true}
// default multiple selection in filter dropdown
let multiple = true;
if ('filterMultiple' in column) {
multiple = column.filterMultiple;
}
let menus = <Menu multiple={multiple}
prefixCls="ant-dropdown-menu"
className="ant-table-filter-dropdown"
onSelect={this.setSelectedKeys}
......
......@@ -79,13 +79,14 @@ var dataSource = new Table.DataSource({
|------------|----------------------------|-----------------|---------------------|---------|
| title | 列头显示文字 | String or React.Element | | |
| dataIndex | 列数据在 data 中对应的 key | String | | |
| colSpan | 表头列合并,设置为 0 时,不渲染 | Number | | |
| colSpan | 表头列合并,设置为 0 时,不渲染 | Number | | |
| key | React 需要的 key | String | | |
| render | 生成复杂数据的渲染函数,参数分别为当前列的值,当前列数据,列索引,@return里面可以设置表格[行/列合并](#demo-colspan-rowspan) | Function(text, record, index) {} | | |
| render | 生成复杂数据的渲染函数,参数分别为当前列的值,当前列数据,列索引,@return里面可以设置表格[行/列合并](#demo-colspan-rowspan) | Function(text, record, index) {} | | |
| filters | 表头的筛选菜单项 | Array | | |
| onFilter | 本地模式下,确定筛选的运行函数 | Function | | |
| filterMultiple | 是否多选 | Boolean | | true |
| sorter | 排序函数,本地模式下为一个函数,远程模式下为布尔值 | Function or Boolean | | 无 |
| width | 列宽度 | String or Number | | 无 |
| width | 列宽度 | String or Number | | 无 |
### dataSource
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册