Incorrect sort type detection with function mDataProp
Incorrect sort type detection with function mDataProp

I noticed when mDataProp is a function, the sort type detection is incorrect, using the 'display' data, rather than the 'sort' data.
For instance, my table displays transactions. The first column displays the transaction date, however I want to sort by the transaction ID from the database to make sure all the transactions are displayed in consecutive order in case two transactions occurred within the same minute. As a result, my raw data rgData[0] contains the database ID representing the transaction, and I want to use this ID as my sort key.
When I use the following code, the sorting becomes incorrect because _fnSort() already autodected the sDataType as a 'date' instead of a 'numeric'.
_fnSort() in jquery.dataTables.js:
[code]
for ( k=0, kLen=aDataSort.length ; k
For instance, my table displays transactions. The first column displays the transaction date, however I want to sort by the transaction ID from the database to make sure all the transactions are displayed in consecutive order in case two transactions occurred within the same minute. As a result, my raw data rgData[0] contains the database ID representing the transaction, and I want to use this ID as my sort key.
When I use the following code, the sorting becomes incorrect because _fnSort() already autodected the sDataType as a 'date' instead of a 'numeric'.
_fnSort() in jquery.dataTables.js:
[code]
for ( k=0, kLen=aDataSort.length ; k
This discussion has been closed.
Replies
Actually - it should be using "type" rather than either "display" or "sort" ( http://datatables.net/docs/DataTables/1.9.0/DataTable.defaults.columns.html#mDataProp ) :-).
So in the above code you would want to have:
[code]
if ((eType === 'sort' || eType === 'type') && idSort != undefined)
[/code]
Allan
I can confirm the sDataType === 'numeric' at line ~3830 in jquery.dataTables.js.
I thought that the code for 'type' was the following:
[code]if (eType === 'type')
return 'numeric';
[/code]
Allan