WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] How to set default column to sort? (6 posts)

  1. Darek L
    Member
    Posted 1 year ago #

    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?

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. Darek L
    Member
    Posted 1 year ago #

    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...

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

  5. Darek L
    Member
    Posted 1 year ago #

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

  6. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic