fix: Number compare

- 006 will match abc006
- 1230 will match 1,230 (formatted), 1230 and abc1230
This commit is contained in:
Faris Ansari 2019-06-24 15:08:39 +05:30
parent bbca6d8f60
commit 1a0eba65a0

View File

@ -111,12 +111,12 @@ function getFilterMethod(filter) {
containsNumber(keyword, cells) {
return cells
.filter(cell => {
let hay = numberCompareValue(cell);
if (isNaN(hay)) {
hay = stringCompareValue(cell);
}
const needle = keyword;
return !needle || hay.toString().includes(needle);
let number = parseFloat(keyword, 10);
let string = keyword;
let hayNumber = numberCompareValue(cell);
let hayString = stringCompareValue(cell);
return number === hayNumber || hayString.includes(string);
})
.map(cell => cell.rowIndex);
}
@ -166,7 +166,7 @@ function guessFilter(keyword = '') {
if (isNumber(compareString)) {
return {
type: 'containsNumber',
text: parseFloat(keyword, 10)
text: compareString
};
}