• Resolved Tim Burkart

    (@bigmoxy)


    Hi Tobias,

    I found an example for using custom commands to sort multiple columns. I want to sort the STATE and ZIP columns in ascending order. Here is what I have:

    "order": [[ 4, 'asc' ], [ 5, 'asc' ]]

    However it is not working for me. Can you tell me what I am doing wrong?

    Thank you!

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

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

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    For this to work, sorting must be enabled for that table, by enabling the checkbox on the “Edit” screen. Can you please try that?

    Now, if you then want to prevent the visitor from sorting the table, you could try turning that off by adding this to the “Custom Commands” as well:

    "order": [[ 4, 'asc' ], [ 5, 'asc' ]], "columnDefs": [ "orderable": false, "targets": "_all" ]
    

    Regards,
    Tobias

    • This reply was modified 4 years, 5 months ago by TobiasBg.
    Thread Starter Tim Burkart

    (@bigmoxy)

    Thank you very much Tobias! Enabling table sorting without the columnDefs command works perfectly. However it does not work with the columnDefs command.

    I also noticed that the columnDefs disabled paging.

    Does table sorting have to be enabled to use the Table Row Order extension?

    • This reply was modified 4 years, 5 months ago by Tim Burkart. Reason: correction
    Thread Starter Tim Burkart

    (@bigmoxy)

    Here’s what I have concluded:

    Table sorting must be enabled for both the Table Row Order extension and the order command.

    Using columnDefs command to disable any column sorting capability causes the above not to work.

    Using columnDefs command to disable all column sorting disables table paging.

    I am moving forward with the order command to sort two columns.

    Thank you for your help!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ah, sorry, I made a mistake in that command. Please try again with

    "order": [[ 4, 'asc' ], [ 5, 'asc' ]], "columnDefs": [ { "orderable": false, "targets": "_all" } ]
    

    (Note the extra { and }.)

    Regards,
    Tobias

    Thread Starter Tim Burkart

    (@bigmoxy)

    This is awesome! Thank you very much for the correction! It works perfectly.

    Best regards,
    Tim

    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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with custom sort commands’ is closed to new replies.