Hide the sorting option on all but one column?

Hide the sorting option on all but one column?

richardk1richardk1 Posts: 6Questions: 1Answers: 0

I'd like to default sort a column (know how to do this) AND hide the sorting option on my other columns. Is this possible with DataTables? I can't find the option.
Thanks!

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 2,325Questions: 18Answers: 256
  • richardk1richardk1 Posts: 6Questions: 1Answers: 0

    Thanks tangerine, but I'm using columns orderable for my last column (date). What I want is to NOT have the rest of my columns orderable (while having my date column orderable).

  • kthorngrenkthorngren Posts: 6,084Questions: 21Answers: 1,347
    Answer ✓

    As Tangerine mentioned you would use columns.orderable and set all but the last to false. Something like this example:
    http://live.datatables.net/muqogixo/1/edit

    Kevin

  • richardk1richardk1 Posts: 6Questions: 1Answers: 0

    Thank you for clarifying kthorngren, much appreciated. And to tangerine: Please accept my apology as it seems you answered it already. Thank you too.

  • tangerinetangerine Posts: 2,325Questions: 18Answers: 256

    No problem. You're welcome.

  • richardk1richardk1 Posts: 6Questions: 1Answers: 0
    edited January 23

    Hi tangerine (or someone else?), I really didn't want to bug anyone (again), but I have tried so many different combinations to get this to work in the table tag and none do.

    Could some please spell it out for me before I go bald?

    I use wet4, using a cms with no option to add custom javascript. This is what I have so far:

    <table class="wb-tables table table-bordered table-hover mrgn-tp-lg" data-wb-tables="{&quot;order&quot;: [1, &quot;asc&quot;]}" data-page-length="50">

    Now, how do I add this to it?:
    columnDefs: [
    {
    targets: [0, 1, 2, 3, 4],
    orderable: false

    Thanks so much if someone can help.

  • kthorngrenkthorngren Posts: 6,084Questions: 21Answers: 1,347
    Answer ✓

    That's a good question. You would do this:
    data-column-defs='[{"targets": [0,1,2], "orderable": false}]'

    For example:
    http://live.datatables.net/nozifibi/1/edit

    It also sets the initial table order to one of the other columns.

    Kevin

  • richardk1richardk1 Posts: 6Questions: 1Answers: 0
    edited January 24

    Thank you very much Kevin. I'll give that a try tomorrow morning. I'll have to exchange the " with &quot; and other stuff (due to my cms), but it should be fine.
    Much appreciated!

  • richardk1richardk1 Posts: 6Questions: 1Answers: 0

    Worked great! Thanks Kevin :)

Sign In or Register to comment.