Within my data table, there exists a column that displays numeric values in formatted currency format such as "$5,66666.77 USD". Here is the segment of the Jquery table definition responsible for this column:
data: "amount",
orderable: true,
searchable: false,
render: (data, type, row) => {
var formattedAmount = "$" + data.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,") + " " + "USD";
return formattedAmount;
}
While sorting works correctly without the "USD" suffix, including it causes the sorting to treat the values like strings. Is there a workaround available for this issue? Can an alternate value be defined for the sort data?
The Typescript typings are being utilized here.
The "data" attribute accepts ObjectColumnData
, which I attempted to use with a specified sort field, but it did not produce the intended result.
interface ObjectColumnData {
_: string;
filter?: string;
display?: string;
type?: string;
sort?: string;
}
Do I need to create a custom sort function to address this situation?