Skip to content

Commit

Permalink
fix #1248
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Apr 25, 2017
1 parent 1a6ca0a commit 61a2d8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/filters/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ class NumberFilter extends Component {

getNumberOptions() {
const optionTags = [];
const { options } = this.props;
const { options, withoutEmptyOption } = this.props;

optionTags.push(
<option key='-1' value=''>
{ this.props.placeholder || `Select ${this.props.columnName}...` }
</option>
);
if (!withoutEmptyOption) {
optionTags.push(
<option key='-1' value=''>
{ this.props.placeholder || `Select ${this.props.columnName}...` }
</option>
);
}
for (let i = 0; i < options.length; i++) {
optionTags.push(<option key={ i } value={ options[i] }>{ options[i] }</option>);
}
Expand Down
10 changes: 6 additions & 4 deletions src/filters/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ class SelectFilter extends Component {

getOptions() {
const optionTags = [];
const { options, placeholder, columnName, selectText } = this.props;
const { options, placeholder, columnName, selectText, withoutEmptyOption } = this.props;
const selectTextValue = (selectText !== undefined) ? selectText : 'Select';
optionTags.push((
<option key='-1' value=''>{ placeholder || `${selectTextValue} ${columnName}...` }</option>
));
if (!withoutEmptyOption) {
optionTags.push((
<option key='-1' value=''>{ placeholder || `${selectTextValue} ${columnName}...` }</option>
));
}
Object.keys(options).map(key => {
optionTags.push(<option key={ key } value={ key }>{ options[key] + '' }</option>);
});
Expand Down

0 comments on commit 61a2d8c

Please sign in to comment.