_fnDetectType should prefer user defined types

_fnDetectType should prefer user defined types

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

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-- )

i.s.o

for ( var i=0 ; i

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 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:

    [code]
    jQuery.fn.dataTableExt.aTypes.unshift( function (sType) { ... } );
    [/code]

    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.

    Regards,
    Allan
This discussion has been closed.