diff --git a/cosmoz-omnitable-column-number.html b/cosmoz-omnitable-column-number.html index 0855ba23..376c10fa 100644 --- a/cosmoz-omnitable-column-number.html +++ b/cosmoz-omnitable-column-number.html @@ -93,6 +93,35 @@

[[ 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.minimumFractionDigits; + if (decimals !== null) { + const d = Math.pow(10, decimals), + temp = parseInt(value * d, 10) / d; + return temp.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 6cbbcebf..a0a038ca 100644 --- a/test/range.html +++ b/test/range.html @@ -20,7 +20,7 @@