WordPress.org

Ready to get started?Download WordPress

Forums

WP-Table Reloaded
[resolved] - Disabling sort for only one column (11 posts)

  1. swollenfox
    Member
    Posted 3 years ago #

    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!

  2. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    this is possible with additional commands for the DataTables JavaScript library. For more information on this, take a look here (the "bSortable entry): http://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

  3. swollenfox
    Member
    Posted 3 years ago #

    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!

  4. MaceEcam
    Member
    Posted 3 years ago #

    I also want them to be able to search only one column. The table is here
    : http://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.

  5. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    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 http://datatables.net/usage/columns)

    Best wishes,
    Tobias

  6. MaceEcam
    Member
    Posted 3 years ago #

    This works! Thank you so much!

  7. MaceEcam
    Member
    Posted 3 years ago #

    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:

    http://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.

  8. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    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

  9. MaceEcam
    Member
    Posted 3 years ago #

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

  10. Nitesh
    Member
    Posted 3 years ago #

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

  11. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic