Browse Source

Use Radio in filter menu filterMultiple=false, close #1880

pull/1933/head
afc163 9 years ago
parent
commit
1688a8724b
  1. 25
      components/table/filterDropdown.jsx
  2. 4
      components/table/style/index.less

25
components/table/filterDropdown.jsx

@ -3,6 +3,7 @@ import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
import Dropdown from '../dropdown';
import Icon from '../icon';
import Checkbox from '../checkbox';
import Radio from '../radio';
export default class FilterMenu extends React.Component {
static defaultProps = {
@ -53,9 +54,15 @@ export default class FilterMenu extends React.Component {
}
renderMenuItem(item) {
const { column } = this.props;
const multiple = ('filterMultiple' in column) ? column.filterMultiple : true;
return (
<MenuItem key={item.value}>
<Checkbox checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
{
multiple
? <Checkbox checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
: <Radio checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
}
<span>{item.text}</span>
</MenuItem>
);
@ -95,13 +102,11 @@ export default class FilterMenu extends React.Component {
}
render() {
let { column, locale } = this.props;
const { column, locale } = this.props;
// default multiple selection in filter dropdown
let multiple = true;
if ('filterMultiple' in column) {
multiple = column.filterMultiple;
}
let menus = (
const multiple = ('filterMultiple' in column) ? column.filterMultiple : true;
const menus = (
<div className="ant-table-filter-dropdown">
<Menu multiple={multiple}
onClick={this.handleMenuItemClick}
@ -124,10 +129,8 @@ export default class FilterMenu extends React.Component {
</div>
);
let dropdownSelectedClass = '';
if (this.props.selectedKeys.length > 0) {
dropdownSelectedClass = 'ant-table-filter-selected';
}
const dropdownSelectedClass = (this.props.selectedKeys.length > 0)
? 'ant-table-filter-selected' : '';
return (
<Dropdown trigger={['click']}

4
components/table/style/index.less

@ -266,6 +266,10 @@
box-shadow: none;
border-radius: @border-radius-base @border-radius-base 0 0;
&-item > label + span {
margin-left: 8px;
}
&-sub {
border-radius: @border-radius-base;
border: 1px solid @border-color-base;

Loading…
Cancel
Save