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]
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
There isn't an
ajax.order
option in DataTables. Nor actually is there anajax.columns
option. They should both be at the top level - seeorder
andcolumns
.Allan
thank u allan