DISABLE SORTING OF A COLUMN WHEN USING DATATABLES

$('#orders').DataTable({
    "columnDefs": [ { orderable: false, targets: [1,2,3] } ],
    "scrollCollapse": true,
    "paging": false,
    "sPaginationType": "full_numbers",
    "bPaginate": true,
    "bLengthChange": true,
    "bFilter": true,
    "bSort": true,
    "bInfo": true,
    "bAutoWidth": false,
    "bProcessing": true,
    "dom": 'Bfrtip',
    language: {
        oPaginate: {
            sNext: '<i class="fa fa-angle-right"></i>',
            sPrevious: '<i class="fa fa-angle-left"></i>',
            sFirst: '<i class="fa fa-angle-double-left"></i>',
            sLast: '<i class="fa fa-angle-double-right"></i>'        }
    },
    buttons: [
        {
            extend: 'csvHtml5',
            text: '<i class="fa fa-file-text-o"></i>',
            titleAttr: 'CSV',
            exportOptions: {
                columns: "thead th:not(.noExport)",
                orthogonal: 'export'            }
        },
        {
            extend: 'excelHtml5',
            text: '<i class="fa fa-file-excel-o"></i>',
            titleAttr: 'Excel',
            exportOptions: {
                columns: "thead th:not(.noExport)",
                orthogonal: 'export'            },

            customize: function (xlsx) {
                console.log(xlsx);
                var sheet = xlsx.xl.worksheets['sheet1.xml'];
                $('row c[r^="A"]', sheet).attr('s', '50'); //<-- left aligned text $('row c[r^="C"]', sheet).attr('s', '55'); //<-- wrapped text $('row:first c', sheet).attr('s', '32');
            }
        },
        {
            extend: 'pdfHtml5',
            text: '<i class="fa fa-file-pdf-o"></i>',
            titleAttr: 'PDF',
            exportOptions: {
                columns: "thead th:not(.noExport)",
                orthogonal: 'export'            }
        },
        {
            extend: 'print',
            text: '<i class="fa fa-print"></i>',
            titleAttr: 'Print',
            exportOptions: {
                columns: "thead th:not(.noExport)",
                orthogonal: 'export'            }
        }
    ]
});

Popular posts from this blog

Ajax Toggle(on/off) on-click Update

Yii Framework In Update Time View Image In Form