Search code examples
phpzend-frameworkdatatable

disable sort icon in datatable not working for first column


I'm using "bSortable": false and "orderable": false but still sort asc icon visible in first column header. I have tried "bsort":false and "orderable": false, "targets": "_all" but still the icon is visible.

If i use "aaSorting":[] this it throws

Undefined variable: orderColumn

Mycode:

var test_table = $('#testDataTable').DataTable({
                // "lengthMenu": [[10, 50, 100,150,200], [10, 50, 100,150,200]],
                "lengthMenu": [[25, 50, 100], [25, 50, 100]],
                "iDisplayLength": 25,
                "sScrollX" : "100%",
                "scrollX" : true,
                "processing" : true,
                "serverSide" : true,
                "destroy":true,

                "ajax" : { 
                            url: "/test/datatable.php", 
                            type: 'POST',
                            data: { status: 'ok' }
                        },
                'columnDefs' : [{"searchable": true, "orderable": false, "targets": '_all' }, {"width": "12%", 'targets': [3,4,5] }]
            });

Thanks in advance.


Solution

  • Change your code to this:

    For me this works all the time ;)

    var test_table = $('#testDataTable').DataTable({
                    // "lengthMenu": [[10, 50, 100,150,200], [10, 50, 100,150,200]],
                    "lengthMenu": [[25, 50, 100], [25, 50, 100]],
                    "iDisplayLength": 25,
                    "sScrollX" : "100%",
                    "scrollX" : true,
                    "processing" : true,
                    "serverSide" : true,
                    "destroy":true,
    
                    "ajax" : { 
                                url: "/test/datatable.php", 
                                type: 'POST',
                                data: { status: 'ok' }
                            },
                    "aoColumnDefs": [{ "bSortable": false, "aTargets": [ "_all" ] }],
                    "aaSorting": []
                });