Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

Try this:

 oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
share|improve this answer
    
It will sort immediately with columns 0 and 1. –  Manie Aug 9 '10 at 6:27
up vote 0 down vote accepted

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 );
share|improve this answer
    
Hi, Could you post your answer. I need same thing. –  Raje Nov 22 '12 at 8:26
    
It was more than two years ago, but I think the answer is right there: use the aaSort function, but patch your script beforehand. –  Stefan T Nov 24 '12 at 6:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.