How to remove sort on the first column in this example?

How to remove sort on the first column in this example?

malex2051malex2051 Posts: 2Questions: 1Answers: 0

Hi, im trying to remover the order on first column of the following example but im not being able to do it.

https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html

Can someone help pls?

Answers

  • kthorngrenkthorngren Posts: 20,270Questions: 26Answers: 4,765

    The columns.orderable removes the ability of the user to sort the defined columns.

    Kevin

  • malex2051malex2051 Posts: 2Questions: 1Answers: 0

    i've tried that but it isnt working.

    I adapted that code to my table like this:

    ```

    var table = $('#tabela').DataTable( {
        orderCellsTop: true,
        responsive: true,
        order:[],
        fixedHeader: true,
        dom: 'Bfrtip',
        initComplete: function () {
            this.api().columns('.filtro').every( function () {
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
    
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                    } );
    
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        }
    } );
    

    ```

  • kthorngrenkthorngren Posts: 20,270Questions: 26Answers: 4,765
    edited September 2019

    i've tried that but it isnt working.

    What exactly isn't working?

    Using columns.orderable works in this example:
    http://live.datatables.net/sotavize/1/edit

    Click on another column and you will see that you can order column 0. Or is it that you want the default order to be another column? If so use order to set your initial order.

    If this doesn't help then please be more specific about what you want.

    Kevin

This discussion has been closed.