aaSorting problems

aaSorting problems

mimicmimic Posts: 43Questions: 0Answers: 0
edited November 2009 in Bug reports
I have a problem with aaSorting. In 1.5.4 (I do not know about before) I have to click twice on an arrow to reverse a presorted column. This is happening even on example page: http://datatables.net/examples/basic_init/table_sorting.html - try to reverse sort of "CSS grade" column. You will have to click twice.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi mimic,

    Thanks for bringing this to my attention. The bug is actually in the example, rather than in DataTables itself. There is some new functionality in 1.5.4 which makes the sorting control that you the developer has much more flexible, but it also means that we might need to provide a little more information in some cases - such as this one!

    By default DataTables will use the ordering "asc", "desc" for sorting, but we want to switch this around for the example here. Therefore, asSorting must be used for this specific column to over rule DataTables' default. Have a look at the example, and come back with any questions you might have.

    Regards,
    Allan
  • mimicmimic Posts: 43Questions: 0Answers: 0
    OK, but this is a workaround for me. If I define sort order of a column as ["asc", "desc"] and say that I want it to start at "desc" that it should correctly cycle to "asc" next time.

    Otherwise there is no use for second value in aaSorting, it could be simply something like:

    [code]
    "aaSorting": [4],
    [/code]

    what would mean sort by 4th column initially. And it would sort it according to the first element of aoColumns' asSorting (or default).
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes, and I agree - the second parameter in aaSorting is effectively redundant now. This is something that I have considered for the next major release of DataTables. I don't want to include it right now as it might break backwards compatibility, but it is a reasonable thing to do in future I think. Of course, if this becomes a common issue with 1.5.x then I will consider making the change in this branch.

    Regards,
    Allan
  • mimicmimic Posts: 43Questions: 0Answers: 0
    There is also another problem with current approach. Namely if I after page load order by some other column and then want to order by initial column (which was ordered in decreasing order) I get decreasing order first (as specified with asSorting). So it is not possible to say "I want for all columns first asc and then desc order, but for this column I want that when page loads it is in decreasing order".
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi mimic,

    It is possible, but we come around back in a loop to the reason why you first opened this discussion - DataTables would then move from the sorting direction that you have given it to the asSorting direction, which could leave it in the same state... Perhaps one option might be use the second array element in aaSorting as an integer which would specific the asSorting element which should be used for initial sorting - but that might get a bit complicated for newcomers...

    Regards,
    Allan
  • mimicmimic Posts: 43Questions: 0Answers: 0
    I will then have to wait for next major release. I hope all this will be fixed there.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi mimic,

    It could be a little while... :-). I'll see how this feature goes down in the 1.5.x series, and if it needs changing fairly quickly due to confusion. I have been thinking about making 1.6.x a fairly rapid release (relative to the several months for 1.5.x), but haven't had a chance to move on that yet...

    Regards,
    Allan
This discussion has been closed.