I have several columns that are formatted in HTML, or where the data presented isn’t directly sortable. For instance, I have a column called x_area
that shows areas like this:
900 m²
40.4 ha
102.1 ha
365 m²
Areas represented as m² look like 365 m<sup>2</sup>
. Sorted into ascending order, they should look like this:
365 m²
900 m²
40.4 ha
102.1 ha
Clearly, they can’t be sorted either textually or numerically. I can do it with a custom comparator, but parsing the areas is costly. However, I do have a column s_area_size
that contains the raw area in m², and the sorted values look like this:
365
900
404000
1021000
So I’m wondering if you’d consider introducing a sortOn
attribute to the multiColumnSorting key. Then, when someone clicks the column header, the value from the sortOn
attribute is passed to the comparator instead of the value from the cell.
The column item would then look like this:
{
data: 'x_area',
title: 'Area',
multiColumnSorting: {
sortOn: 's_area_size'
},
className: 'text-right',
renderer: 'html'
}
Thanks for your consideration