• Resolved Darek L

    (@darekl)


    I have small website about coaching here: coaching.dariusz-licznerski.pl

    I use there TablePress plugin with fixed kk Star Ratings plugin. I made custom type for ratings as well.

    … but how to set default column to sort? It’s not working from admin panel because of the custom type and this sort must be “on the fly” not “static”. So… I should use this aaSorting?

    I put such code to the js file at the end but it’s not working…

    …any idea?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks of your question.

    So, you want an initial sorting on the first column, when the table is viewed?

    Then please try adding this to the “Custom Commands” textfield on the “Edit” screen of the table:

    "aaSorting": [[0,'desc']]

    The aaSorting would only change the available sort orders, but it would not perform the actual sort. Also, adding that code to your JS file is not necessary.

    Regards,
    Tobias

    Thread Starter Darek L

    (@darekl)

    Thanks Tobias for quick help.

    I found fnSort and use it in order to avoid error related to the second table initialisation.

    Finally I get it to work with such code:

    // Default sort
    var oTable;
    oTable = jQuery('#tablepress-1').dataTable();
    oTable.fnSort( [ [0,'desc'] ] );
    oTable = jQuery('#tablepress-2').dataTable();
    oTable.fnSort( [ [0,'desc'] ] );

    Looks like it is what l was looking for…

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    second table initialisation? I’m not sure where that should be coming from, but great to hear that you found a solution!

    Best wishes,
    Tobias

    Thread Starter Darek L

    (@darekl)

    Yes, when I put aaSorting code into js file it popup window with second table initialisation… yes but everything is fine now, resolved, thanks.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    that’s why you shouldn’t put aaSorting into the JS file, but into the “Custom Commands” text field in TablePress! ??

    But if it now works, everything is fine, indeed! ??

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to set default column to sort?’ is closed to new replies.