WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Substitute word for numbers for sorting issues (6 posts)

  1. inkspill
    Member
    Posted 1 year ago #

    Is there a way to have a number such as 9999 be the information used for sorting but display "Unlimited" (without quotes) when the user views the table?

    http://wordpress.org/extend/plugins/tablepress/

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    thanks for your question.

    Yes, this is possible with some extra work: Basically, you'll have to maintain two columns with this data, where one column holds the data that is used for sorting (and where you would use "9999"), and the other column holds the data that is displayed in the table (where you would then use "Unlimited").

    To make this work, you'll then need this "Custom Command" for the DataTables JS library (to be entered into the corresponding field on the table's "Edit" screen):

    "aoColumnDefs": [ { "bVisible": false, "aTargets": [ 3 ] }, { "iDataSort": 3, "aTargets": [ 4 ] } ]

    The "3" indicates that the fourth column contains the data for the sorting (counting starts with 0 in the code), while the "4" indicates, that the fifth column contains the data that shall be displayed.

    Regards,
    Tobias

  3. inkspill
    Member
    Posted 1 year ago #

    Thank you Tobias.
    I can confirm the above method works.

    If I wanted to use the above example on two different column substitutions, would the code below be the correct/efficient method?

    "aoColumnDefs": [ { "bVisible": false, "aTargets": [ 1,3 ] }, { "iDataSort": 1, "aTargets": [ 2 ] }, { "iDataSort": 3, "aTargets": [ 4 ] } ]

    So I am hidding column 2 and column 4.
    Column 2 has the sort data while column 3 has the display data.
    Column 4 has the sort data while column 5 has the display data.

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    great to hear that this worked! :-)

    And yes, your code for two columns looks correct, and I can't think of a shorter version. Very nice!

    Best wishes,
    Tobias

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

  5. inkspill
    Member
    Posted 1 year ago #

    I appreciate your help.
    Will leave rating. You will also be getting a donation.

    Thanks

  6. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    you are very welcome!
    And thanks for wanting to rate and donate, I really appreciate it!

    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic