I am trying to sort a DataTable column based on a custom attribute that the column has. My table look like this:
<table class="dataTable">
<thead>
<tr>
<th width="15%" scope="col" class="currency-field">${msg_amountLabel}</th>
</tr>
</thead>
<tbody>
<tr>
<td data-raw="${order.totalPrice}" class="order-history-list-price">${order.formattedPrice}</td>
</tr>
</tbody>
</table>
And my JS looks like this:
jQuery.fn.dataTableExt.oSort["currency-desc"] = function (a, b) {
return 1;
};
jQuery.fn.dataTableExt.oSort["currency-asc"] = function (a, b) {
return 0;
}
tableObject.DataTable({
"info": false,
"paging": false,
"order": orderObject,
"columnDefs": [{
"targets" : 'currency-field',
"type": "currency",
"data": "data-raw"
}]
});
For now I have dummy values in my sorters to test if they are being called, I was expecting to receive the element in the sorters but I receive only the value.
Is it possible to pass some parameter to the columnnDefs to infor that I want the value from the attribute data-raw? Or any other way to inform the dataTable sort to use the data-raw instead of the field value?