Remove the sort arrous

Remove the sort arrous

spacemancwspacemancw Posts: 34Questions: 9Answers: 0

I want to remove the sort arrows from my table.

I have looked at the info at https://datatables.net/forums/discussion/comment/200892/#Comment_200892 and tried them all, but the sort arrows still show up for me.

I am using DataTables-1.11.3
I want to remove the sort arrows in the column headers.
I have tried
"ordering": 'false',
and
"order": [],

I have tried them both together.

I have tried the CSS in the link above.

I have tried

.no-sort::after { display: none!important; }
.no-sort { pointer-events: none!important; cursor: default!important; }

and added the class to the column

<th class="no-sort">

Any help would be appreciated.

Answers

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    Setting ordering to false works in this test case with 1.11.3:
    https://live.datatables.net/lewomuvu/1/edit

    If this doesn't help then please post a link to a test case replicating the issue. Feel free to update my test case.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • spacemancwspacemancw Posts: 34Questions: 9Answers: 0

    Kevin,

    ordering: false,

    turns off ordering all together. I just want to hide the arrows, I don't want the arrows. I got it to work using the CSS already on the post I referenced. I had to use the one you posted and the one from @awariat together.

    /* Part 1 */
    table.dataTable thead .sorting_asc {
        background-image: url(../images/sort_asc.png) !important;
    }
    
    table.dataTable thead .sorting_desc {
        background-image: url(../images/sort_desc.png) !important;
    }
    
    table.dataTable thead .sorting {
        background-image: url(../images/sort_both.png);
    }
    
    
    /* Part 2 */
    table.dataTable>thead .sorting::before,
    table.dataTable>thead .sorting_asc::before,
    table.dataTable>thead .sorting_desc::before,
    table.dataTable>thead .sorting_asc_disabled::before,
    table.dataTable>thead .sorting_desc_disabled::before {
        right: 0 !important;
        content: "" !important;
    }
    
     table.dataTable>thead .sorting::after,
     table.dataTable>thead .sorting_asc::after,
     table.dataTable>thead .sorting_desc::after,
     table.dataTable>thead .sorting_asc_disabled::after,
     table.dataTable>thead .sorting_desc_disabled::after {
        right: 0 !important;
        content: "" !important;
    }
    
     table.dataTable>thead>tr>th:not(.sorting_disabled),
     table.dataTable>thead>tr>td:not(.sorting_disabled) {
        padding-right: 0px !important;
        padding-left: 0px !important;
    }
    
     table.dataTable>thead>tr>th,
     table.dataTable>thead>tr>td {
        padding-right: 0px !important;
        padding-left: 0px !important;
    }
    

    this works and I can still order like this :

    "order": [[ 0, 'desc' ]],

    Is there an easier way in later versions?

    thanks

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    edited November 8

    For DataTables 2+

    table.dataTable span.dt-column-order {
      display: none;
    }
    

    You might want to add styles to remove the padding as well if you like.

    Allan

  • rf1234rf1234 Posts: 2,988Questions: 87Answers: 421
    edited November 8

    This works for older data tables versions. Just tested it.

    table.dataTable th.sorting::after {
        display: none;
    }
    
  • spacemancwspacemancw Posts: 34Questions: 9Answers: 0

    I tried @allan and @rf1234 ... neither worked for me.
    I'll keep using what I posted above.

    thanks

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Here is a live example with DT 2: https://live.datatables.net/tegihupi/1/edit .

Sign In or Register to comment.