order:[[5,'desc']] ajax dosent set the value for order[0][column] and order[0][dir]

order:[[5,'desc']] ajax dosent set the value for order[0][column] and order[0][dir]

KaranSisoKaranSiso Posts: 2Questions: 1Answers: 0

i want my datatable to be sorted on first load of page so is written order:[[5,'desc']] in ajax but it is not setting value for order[0][column]=5 and order[0][dir]=asc, insted of it its setting default value... i m doing this in MVC Pattern (Code Igniter)... below is my jscrit.........................

...........................................................................................................................................................................................................

jQuery(document).ready(function()
{
jQuery("#adsTable").DataTable(
{
"processing": true,
"serverSide": true,
"filter":true,

      "ajax":{
              "url":"<?php echo base_url().'index.php/pagination/fetchRecordsforDatatable'; ?>",
              "type" :'POST',
              "dataType":"json",
              "order":[[5,'desc']],
              "data":{  '<?php echo $this->security->get_csrf_token_name(); ?>' : '<?php echo $this->security->get_csrf_hash(); ?>' },
              "columns":[
                          { "data": "phone1" },
                          { "data": "title" },
                          { "data": "email" },
                          { "data": "category" },
                          { "data": "ad_text"},
                          { "data": "start_date"},
                          { "data": "end_date"},
                          { "data": "status"},
                        ]  
             },
    });

});

.........................................................................................................................................................................................................

and what i got in post in ajax is..

csrf_test_name
6db8956b502b4c15a17d1c6eaf272a02
draw 1
length 10
order[0][column] 0
order[0][dir] asc
start 0

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    There isn't an ajax.order option in DataTables. Nor actually is there an ajax.columns option. They should both be at the top level - see order and columns.

    Allan

  • KaranSisoKaranSiso Posts: 2Questions: 1Answers: 0

    thank u allan

This discussion has been closed.