Datatable Sorting Not Working

Datatable Sorting Not Working

vijaynailbitervijaynailbiter Posts: 6Questions: 3Answers: 0
edited August 2015 in Free community support

Guys,

I am using jquery data table with server side processing. It's working fine with normal searching and all. but it's not sorting the data properly.. data can't sort.

tableobj = $('#datatable').dataTable({

            sAjaxSource: 'ajax url',
            aaSorting: [[ 0, false ],[ 1, "desc" ]],
            bProcessing: true,
            bServerSide: true, 
            iDisplayLength: '100',
            aoColumns: [{
                 'targets': 0,
                 'searchable':false,
                 'orderable':false,
                 'className': 'dt-body-center',
                 'render': function (data, type, full, meta){

                    if($("#checkall").is(":checked")){
                        return '<label><input checked="checked" type="checkbox" name="check[]" value="' + $('<div/>').text(data).html() + '"></label>';
                    }
                    else {
                        return '<label><input type="checkbox" name="checkbox[]" value="' + $('<div/>').text(data).html() + '"></label>';
                    }
                }
            },null,
            null,
            null,
            null
            ],

            processing : true,
            fnDrawCallback: function() {
                var oSettings = this.fnSettings();
                var iTotalRecords = oSettings.fnRecordsTotal();
                $("#total_count").html(iTotalRecords);    
            },  
            rowCallback: function(row, data, dataIndex){
                if($.inArray(data[0], rows_selected) !== -1){
                   $(row).find('input[type="checkbox"]').prop('checked', true);
                   $(row).addClass('selected');
                }
            }         
        });

Can you guys help me out to resolve this issue.

Thanks

Answers

  • vijaynailbitervijaynailbiter Posts: 6Questions: 3Answers: 0
    edited August 2015

    I am using serverSide Processing

  • johngtrsjohngtrs Posts: 33Questions: 2Answers: 0

    Ehhhh try to remove "'orderable':false,"

  • vijaynailbitervijaynailbiter Posts: 6Questions: 3Answers: 0

    Yes but this is for single collumn not for all.

  • johngtrsjohngtrs Posts: 33Questions: 2Answers: 0

    Why your other columns are null ? You should set some datas. I'll give you an example :

                  columns: [
                      {data: "value1"},
                      {data: "value2"},
                      {data: "value3"},
                      {data: searchable: false, orderable: true},
                      {data: searchable: true, orderable: false}
                  ]
    
This discussion has been closed.