Bug in Criteria.numFmtConditions.>.search function of searchBuilder
Bug in Criteria.numFmtConditions.>.search function of searchBuilder

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Original code in dataTables.searchBuilder.js:
Criteria.numFmtConditions = {
'>': {
conditionName: 'Equals',
init: Criteria.initSelect,
inputValue: Criteria.inputValueSelect,
isInputValid: Criteria.isInputValidSelect,
search: function (value, comparison) {
var val = value.replace(/[^0-9.]/g, '');
var comp0 = comparison[0].replace(/[^0-9.]/g, '');
return +val > +comp0;
}
}
}
The search function is not correct.
function search(value, comparison) {
var val = value.replace(/[^0-9.]/g, '');
var comp0 = comparison[0].replace(/[^0-9.]/g, '');
return +val > +comp0;
}
result = search('-3%', ['2%']);
console.log(result);
The result is true
, but should be false
.
Suggest to use Numeral.js (http://numeraljs.com/) to compare.
function search(value, comparison) {
var val = numeral(value).value();
var comp0 = numeral(comparison[0]).value();
return val > comp0;
}
result = search('-3%', ['2%']);
console.log(result);
The result is false
.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @Mikea ,
Thanks for pointing this out, it appears to be something that we have overlooked. I've raised an issue internally (DD-1704 for my reference) and will report back here when there is an update.
Thanks,
Sandy
Hi @Mikea ,
That should be the issue fixed now as you can see at this example.
Thanks again for pointing this out to us,
Sandy
Hi @sandy
Not fixed in
Criteria.numFmtConditions.between
andCriteria.numFmtConditions.!between
.Hi @Mikea,
Apologies, poor show from me to miss those. They are fixed now.
Thanks,
Sandy