Question

I can't find a solution for this in DataTables plugin. What I want is to have secondary sorting. What I mean by that is - for example, I have a table with product name and price, something like this:

    NAME               PRICE
    A product          22.00 $
    C product          50.00 $
    B product          50.00 $
    D product          50.00 $
    E product          26.00 $
    F product          12.00 $

When the user clicks on PRICE this happens:

    NAME               PRICE
    F product          12.00 $
    A product          22.00 $
    E product          26.00 $
    C product          50.00 $
    B product          50.00 $
    D product          50.00 $

But I need this to happen:

    NAME               PRICE
    F product          12.00 $
    A product          22.00 $
    E product          26.00 $
    B product          50.00 $
    C product          50.00 $
    D product          50.00 $

    (note the last three products - they are sorted a-z)

Or basically, I need what's described here.

Thanks in advance if you have any ideas!

Was it helpful?

Solution 2

Sorry, forgot to answer here. I've found a solution - use the aaSort function but you need to patch it in the script. Change line 4085 to:

aaSort = oSettings.aaSorting.concat( oSettings.aaSortingFixed );

OTHER TIPS

Try this:

 oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top