diff --git a/cosmoz-omnitable-column-number.html b/cosmoz-omnitable-column-number.html index 0855ba23..75425a29 100644 --- a/cosmoz-omnitable-column-number.html +++ b/cosmoz-omnitable-column-number.html @@ -93,6 +93,33 @@

[[ title ]]

return new Intl.NumberFormat(locale || undefined, options); }, + /** + * Get the comparable value of an item. + * + * @param {Object} item Item to be processed + * @param {String} valuePath Property path + * @returns {Number|void} Valid value or void + */ + getComparableValue(item, valuePath) { + if (item == null) { + return; + } + let value = item; + if (valuePath != null) { + value = this.get(valuePath, item); + } + value = this.toValue(value); + if (value == null) { + return; + } + + const decimals = this.maximumFractionDigits; + if (decimals !== null) { + return value.toFixed(decimals); + } + return value; + }, + renderValue(value, formatter = this.formatter) { const number = this.toNumber(value); if (number == null) { diff --git a/test/range.html b/test/range.html index 626768b3..e31c29f2 100644 --- a/test/range.html +++ b/test/range.html @@ -20,7 +20,7 @@