• Resolved swollenfox

    (@swollenfox)


    My table has 4 columns, and I want 3 to be sortable. However, I’d like the first column to be so that no one can sort it. I’ve been looking around and can’t seem to find much on this topic, so I was wondering if anyone knew if there’s anyway to get this done.

    Thanks for any help!

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

    (@tobiasbg)

    Hi,

    this is possible with additional commands for the DataTables JavaScript library. For more information on this, take a look here (the “bSortable entry): https://datatables.net/usage/columns#bSortable
    The JavaScript command that you get from there will need to go into the “Custom Commands” textfield on the “Edit” screen of the table, in the “DataTables JavaScript library features” section.

    Hope this helps!
    Tobias

    Thread Starter swollenfox

    (@swollenfox)

    Hi Tobias,

    Thanks for your help! I’m still having problems though, they’re more extensive though so I created a new thread here.

    I really hope you can help. Thanks!

    I also want them to be able to search only one column. The table is here
    : https://stilwellok.us/product-lines/ra-series-element/
    And I want only the first column to be looked through by the search box. I need this done for several tables, all of which only the first column with be searched.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    please try pasting the following line of code into the “Custom Commands” textfield in the “DataTable JavaScript Options” section on the “Edit” screen of your tables that shall only be sortable and searchable in the first column:

    "aoColumnDefs": [ { "bSortable": true, "aTargets": [ 0 ] }, { "bSortable": false, "aTargets": [ "_all" ] }, { "bSearchable": true, "aTargets": [ 0 ] }, { "bSearchable": false, "aTargets": [ "_all" ] } ]

    (untested, composed with help from https://datatables.net/usage/columns)

    Best wishes,
    Tobias

    This works! Thank you so much!

    One more thing. While looking for the answer to my previous question I found something that may work as an alternate solution on this page:

    https://datatables.net/examples/api/multi_filter.html

    I am referring to the individual search boxes under each filter. This way they could search whatever parts they wanted to. Is it possible to add that to my table? Keep in mind that I don’t know anything about jQuery. If not its no big deal, I can use the solution already presented, but I thought I’d ask all the same.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    in theory this can of course be integrated into a table, but not it is not that easy to include it with the existing code, so that I generally recommend to manually load DataTables plugins into the page. This does however require programming, so you might need to stick with the current solution.

    Regards,
    Tobias

    Ok, thanks. I’ll be sticking with the current solution.

    hi
    i have 9 column in my table and i just want to sort table only by first 2 column how can i do?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that should be possible by adding the following code to the “Custom Commands” text field in the “DataTables JavaScript features” section on the “Edit” screen of your table:

    "aoColumnDefs": [ { "bSortable": true, "aTargets": [ 0, 1 ] }, { "bSortable": false, "aTargets": [ "_all" ] } ]

    Regards,
    Tobias

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WP-Table Reloaded] – Disabling sort for only one column’ is closed to new replies.