_fnDetectType should prefer user defined types

_fnDetectType should prefer user defined types

pieterpieter Posts: 1Questions: 0Answers: 0
edited April 2009 in Bug reports

I had written a small extension that generates locale aware numbers, and added a type and sorting functions for those locale numbers for use in DataTables.

The issue I ran into is that for e.g. German locale ('de'), the . is used as thousands separator and the , as decimal separator. Now if all numbers in one column are natural numbers between 1 and 1,000,000, they have at most one . and are interpreted by DataTables as a 'numeric', and hence sorting goes wrong.

I think the best way to solve this (and potentially similar) problems is by reversing the _fnDetectType loop

for ( var i=iLen-1 ; i>=0 ; i-- )


for ( var i=0 ; i


  • allanallan Posts: 57,229Questions: 1Answers: 9,111 Site admin
    Hi Pieter,

    I certainly see your point here, developers will often want to have their own types take precedent. However this is easy enough to achieve with what DataTables already presents:

    jQuery.fn.dataTableExt.aTypes.unshift( function (sType) { ... } );

    unshift() will add the new function to the start of the array, rather than at the end like push(). Then your detection type will be the first to run :-)

    I prefer to leave the type detection loop as it currently is since what you are looking for can be achieved at the moment, and it might cause unexpected behaviour to change the order of type detection for current deployments.

This discussion has been closed.