diff --git a/lib/Ardagryd.js b/lib/Ardagryd.js index ba1d56ab..6c2c8b11 100644 --- a/lib/Ardagryd.js +++ b/lib/Ardagryd.js @@ -272,9 +272,10 @@ const defaultConfig = { filterFunction: ({displayValue, expression}) => { if (!(typeof expression === 'string') || expression === '' || expression === undefined || expression === null){return true;} if (displayValue === undefined || displayValue === null) {return false;} - if ((typeof displayValue === 'string' ) && displayValue.toLowerCase().indexOf(expression.toLowerCase()) === -1){ + const valueType = typeof displayValue; + if ((valueType === 'string' ) && displayValue.toLowerCase().indexOf(expression.toLowerCase()) === -1){ return false; - } else if ((typeof displayValue === 'object') || (typeof displayValue === 'number') ){ + } else if (['number', 'boolean', 'object'].indexOf(valueType) !== -1){ return JSON.stringify(displayValue).toLowerCase().indexOf(expression.toLowerCase()) !== -1; } else return true; diff --git a/test/FilterTests.js b/test/FilterTests.js index bbde9257..50a93e3b 100644 --- a/test/FilterTests.js +++ b/test/FilterTests.js @@ -269,7 +269,7 @@ describe('Grid filter tests', function () { expect(grid.find("tbody").children().length).be.equal(1); }); - it('Filter should filte numerical values', ()=>{ + it('Filter should filter numerical values', ()=>{ let grid = mount(); expect(grid.find("tbody").children().length).be.equal(3); @@ -277,6 +277,14 @@ describe('Grid filter tests', function () { expect(grid.find("tbody").children().length).be.equal(2); }); + + it('Filter should filter boolean values', ()=>{ + let grid = mount(); + expect(grid.find("tbody").children().length).be.equal(3); + + grid.setProps({filter: [{columnName: "x", expression: "true"}]}); + expect(grid.find("tbody").children().length).be.equal(2); + }); it('Should use displayValueGetter for default filter function', () => { let grid = mount(