Skip to content

Commit

Permalink
Fix for 737 (#738)
Browse files Browse the repository at this point in the history
* Custom Filter doesn't accept filterList (needed for serverside) #737

* Fixing the example
  • Loading branch information
Avd6977 authored and gabrielliwerant committed Aug 1, 2019
1 parent 6e973d2 commit e4713b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
33 changes: 17 additions & 16 deletions examples/customize-filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ class Example extends React.Component {
options: {
filter: true,
filterType: 'custom',
filterList: [25, 50],
customFilterListRender: v => {
if (v['min'] && v['max']) {
return `Min Age: ${v['min']}, Max Age: ${v['max']}`;
} else if (v['min']) {
return `Min Age: ${v['min']}`;
} else if (v['max']) {
return `Max Age: ${v['max']}`;
if (v[0] && v[1]) {
return `Min Age: ${v[0]}, Max Age: ${v[1]}`;
} else if (v[0]) {
return `Min Age: ${v[0]}`;
} else if (v[1]) {
return `Max Age: ${v[1]}`;
}
return false;
},
filterOptions: {
names: [],
logic(age, filters) {
if (filters['min'] && filters['max']) {
return age < filters['min'] || age > filters['max'];
} else if (filters['min']) {
return age < filters['min'];
} else if (filters['max']) {
return age > filters['max'];
if (filters[0] && filters[1]) {
return age < filters[0] || age > filters[1];
} else if (filters[0]) {
return age < filters[0];
} else if (filters[1]) {
return age > filters[1];
}
return false;
},
Expand All @@ -60,18 +61,18 @@ class Example extends React.Component {
<FormGroup row>
<TextField
label="min"
value={filterList[index]['min'] || ''}
value={filterList[index][0] || ''}
onChange={event => {
filterList[index]['min'] = event.target.value;
filterList[index][0] = event.target.value;
onChange(filterList[index], index, column);
}}
style={{ width: '45%', marginRight: '5%' }}
/>
<TextField
label="max"
value={filterList[index]['max'] || ''}
value={filterList[index][1] || ''}
onChange={event => {
filterList[index]['max'] = event.target.value;
filterList[index][1] = event.target.value;
onChange(filterList[index], index, column);
}}
style={{ width: '45%' }}
Expand Down
1 change: 0 additions & 1 deletion src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MuiTable from '@material-ui/core/Table';
import classnames from 'classnames';
import cloneDeep from 'lodash.clonedeep';
import find from 'lodash.find';
import isEqual from 'lodash.isequal';
import isUndefined from 'lodash.isundefined';
import merge from 'lodash.merge';
import PropTypes from 'prop-types';
Expand Down

0 comments on commit e4713b5

Please sign in to comment.