WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Substitute word for numbers for sorting issues

[Resolved] Substitute word for numbers for sorting issues

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

    @tobiasbg

    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

    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.

    Plugin Author TobiasBg

    @tobiasbg

    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!

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

    Thanks

    Plugin Author TobiasBg

    @tobiasbg

    Hi,

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

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Substitute word for numbers for sorting issues’ is closed to new replies.