Support » Plugin: TablePress » TablePress default sorting

  • Resolved petitegirafe

    (@petitegirafe)


    Hello and thank you for this powerful TablePress tool.
    One of my columns has dates and I would like the table to appear by default with the most recent dates first.
    Tell me how to do it or if the question has already been asked.
    Thank you very much!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I’m not sure that I understand. The table on the page from your link does not seem to have dates?
    Now, it is indeed possible to trigger an automatic sorting on page load, by adding this to the “Custom Commands” text field on the table’s “Edit” screen:

    "order": [ [ 0, "desc" ] ]
    

    where the 0 in this example would refer to the first column of the table (counting starts with 0).

    Regards,
    Tobias

    Thread Starter petitegirafe

    (@petitegirafe)

    Oh what a quick answer!
    Thank you so much.
    My table doesn’t have dates… yet.
    I’ll try your advice

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Thread Starter petitegirafe

    (@petitegirafe)

    I’m sorry, maybe I do something wrong ?
    I added this :
    [table id=11 /] {“order”: [ [ 0, “desc” ] ]}
    And after saving I’ve got this:
    [table id=11 /] {}
    Your code is gone..! I mean it doesn’t stay .

    • This reply was modified 2 months, 1 week ago by petitegirafe.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    where exactly did you add this? You will only need to add

    "order": [ [ 0, "desc" ] ]
    

    into the “Custom Commands” text field on the “Edit” screen of table 11. That field should be empty by default.

    Regards,
    Tobias

    eekostas

    (@eekostas)

    Hello Tobias,
    on the same question i’d like to ask you something:

    i have a table with three columns

    A-Column-> Subject
    B-Column-> Document for downloading (.pdf,.docx)
    C-Column-> Date

    My date format is d/m/y

    Using the above script you’ve suggested -> “order”: [ [ 0, “desc” ] ] in my case “order”: [ [ 2, “desc” ] ] as i want the last column, it doesn’t bring properly the results due to my date format.

    Could you please advise on that?

    Thanks,
    Kostas-

    eekostas

    (@eekostas)

    I’ve found it Tobias.

    For date format day/month/year i had to use the one below:

    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 2 ] } ], “order”: [[ 2, ‘desc’ ]]

    where 2, is my third column which contains the dates.

    Thanks,
    Kostas-

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great! Yes, that’s the best solution here.

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.