0

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!

2 Answers 2

1

Try this:

 oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
Sign up to request clarification or add additional context in comments.

1 Comment

It will sort immediately with columns 0 and 1.
0

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

2 Comments

Hi, Could you post your answer. I need same thing.
It was more than two years ago, but I think the answer is right there: use the aaSort function, but patch your script beforehand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.