Is it possible to disable sorting for one column header?

Is it possible to disable sorting for one column header?

vamiakavamiaka Posts: 10Questions: 1Answers: 1
edited July 2014 in Free community support

I've probably spent way longer than I needed to, so I figured I'd try here for some assistance. I have a sortable table in place (courtesy of DataTables), but I was asked to remove sorting from one column header. I've tried using boolean and on-click code, but no cigar. Here is my test page - http://www.psta.net/testing/tabletest.php

There are two tasks I could use a hand with:
1) Remove the sorting option from "Item Requested."
2) In the search box, make the clear/reset 'x' permanently visible (not just when you enter text).

Any help would be greatly appreciated!!

This question has accepted answers - jump to:

Answers

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    Thank you, tangerine!

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    I tried the above, and it "appears" how they would like it to be. In other words, there is no arrow to indicate the sorting option. However, if you click on 'Item Requested', it still sorts by that column. Thoughts?

    I adjusted my code to this, according to the documentation.

    $(document).ready( function () {
        $('#table_id').DataTable( {
            "order": [ 0, 'desc' ],
            "aoColumnDefs": [
              { "bSortable": false, "aTargets": [ 2 ] } 
              ]
        } );
    } );

    Thank you again, and have a great day!

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin

    Thoughts?

    Yes - please link to a test case showing the issue. With your exact code, it disabled sorting on the third column, as you can see here: http://live.datatables.net/furofuf/1/edit .

    Allan

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    Hi Allan, thanks for chiming in! Here's my test page: http://www.psta.net/testing/tabletest.php

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Why are you including tablesorter.js?!

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    I'm not sure what you mean. They want it to be initially sorted by the first column. That portion is working though.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    If you're going to use DataTables, don't use tablesorter. They are not compatible.

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    Thank you again! I'll try that!

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    Perfect! I just have to figure out the issue with the clear button for the search field, and I'm golden. ^_^ I read that it's an HTML 5 function, so it's only visible on certain browser versions. It's a minor issue though. You made my day!

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Answer ✓

    In the search box, make the clear/reset 'x' permanently visible (not just when you enter text).

    That's entirely up to the browser's implantation of the <input type="search"> element. You would need to replace the element with a custom input control if you wanted control over it.

    Allan

  • vamiakavamiaka Posts: 10Questions: 1Answers: 1

    Gotcha! I'll try to get it sorted soon. Thank you, Allan ^_^

This discussion has been closed.