Browse Source

update filter dropdown function and style

pull/42/head
afc163 10 years ago
parent
commit
0e7f42937f
  1. 27
      components/table/index.jsx
  2. 1
      style/components/dropdown.less
  3. 25
      style/components/table.less
  4. 4
      style/core/base.less
  5. 1
      style/themes/default/custom.less

27
components/table/index.jsx

@ -92,16 +92,18 @@ let AntTable = React.createClass({
this.fetch(); this.fetch();
}, },
handleSelectFilter(column, selected) { handleSelectFilter(column, selected) {
column.selectedFilters = column.selectedFilters || [];
column.selectedFilters.push(selected); column.selectedFilters.push(selected);
}, },
handleDeselectFilter(column, key) { handleDeselectFilter(column, key) {
column.selectedFilters = column.selectedFilters || [];
var index = column.selectedFilters.indexOf(key); var index = column.selectedFilters.indexOf(key);
if (index !== -1) { if (index !== -1) {
column.selectedFilters.splice(index, 1); column.selectedFilters.splice(index, 1);
} }
}, },
handleClearFilters(column) {
column.selectedFilters = [];
this.fetch();
},
handleSelect(e) { handleSelect(e) {
let checked = e.currentTarget.checked; let checked = e.currentTarget.checked;
let currentRowIndex = e.currentTarget.parentElement.parentElement.rowIndex; let currentRowIndex = e.currentTarget.parentElement.parentElement.rowIndex;
@ -169,20 +171,31 @@ let AntTable = React.createClass({
} }
let filterDropdown, menus, sortButton; let filterDropdown, menus, sortButton;
if (column.filters && column.filters.length > 0) { if (column.filters && column.filters.length > 0) {
column.selectedFilters = column.selectedFilters || [];
menus = <Menu multiple={true} menus = <Menu multiple={true}
className="ant-table-filter-dropdown" className="ant-table-filter-dropdown"
onSelect={this.handleSelectFilter.bind(this, column)} onSelect={this.handleSelectFilter.bind(this, column)}
onDeselect={this.handleDeselectFilter.bind(this, column)}> onDeselect={this.handleDeselectFilter.bind(this, column)}
selectedKeys={column.selectedFilters}>
{this.renderMenus(column.filters)} {this.renderMenus(column.filters)}
<Menu.Divider />
<Menu.Item disabled> <Menu.Item disabled>
<button style={{ <a className="ant-table-filter-dropdown-link confirm"
style={{
cursor: 'pointer', cursor: 'pointer',
pointerEvents: 'visible' pointerEvents: 'visible'
}} }}
className="ant-btn ant-btn-primary ant-btn-sm"
onClick={this.handleFilter.bind(this, column)}> onClick={this.handleFilter.bind(this, column)}>
确定
</button> </a>
<a className="ant-table-filter-dropdown-link clear"
style={{
cursor: 'pointer',
pointerEvents: 'visible'
}}
onClick={this.handleClearFilters.bind(this, column)}>
清空
</a>
</Menu.Item> </Menu.Item>
</Menu>; </Menu>;
let dropdownSelectedClass = ''; let dropdownSelectedClass = '';

1
style/components/dropdown.less

@ -99,7 +99,6 @@
&-divider { &-divider {
height: 1px; height: 1px;
margin: 1px 0;
overflow: hidden; overflow: hidden;
background-color: #e5e5e5; background-color: #e5e5e5;
line-height: 0; line-height: 0;

25
style/components/table.less

@ -32,7 +32,30 @@
} }
.@{tablePrefixClass}-filter-dropdown { .@{tablePrefixClass}-filter-dropdown {
min-width: 100px; min-width: 88px;
.ant-dropdown-menu-item {
overflow: hidden;
padding: 7px 8px;
&.ant-dropdown-menu-item-selected:after {
right: 8px;
}
}
}
a.@{tablePrefixClass}-filter-dropdown-link {
color: @link-color;
&:hover {
color: @link-hover-color;
}
&:active {
color: @link-active-color;
}
&.confirm {
float: left;
}
&.clear {
float: right;
}
} }
.@{tablePrefixClass}-filter-selected.anticon-bars { .@{tablePrefixClass}-filter-selected.anticon-bars {

4
style/core/base.less

@ -54,6 +54,10 @@ a {
color: @link-hover-color; color: @link-hover-color;
} }
&:active {
color: @link-active-color;
}
&:active, &:active,
&:hover { &:hover {
outline: 0; outline: 0;

1
style/themes/default/custom.less

@ -25,6 +25,7 @@
// LINK // LINK
@link-color : @primary-color; @link-color : @primary-color;
@link-hover-color : tint(@link-color, 20%); @link-hover-color : tint(@link-color, 20%);
@link-active-color : shade(@link-color, 5%);
@link-hover-decoration : none; @link-hover-decoration : none;
// Disabled cursor for form controls and buttons. // Disabled cursor for form controls and buttons.

Loading…
Cancel
Save