Reputation: 37
I have made following JSBIn in which you can see the code. Due to CORS policy the ajax url I used is not working but it generates following output in which you can see see data is mapped in wrong columns. Please let me know using same data object column names which I have used how to fix this?
https://jsbin.com/ciheragayi/1/edit?html,css,js,output
$(document).ready(function() {
$('#example').DataTable( {
"ajax": "https://a.uguu.se/8MdQchH6NKHJ_CYF.txt",
"processing": true,
"serverSide": true,
colReorder: true,
"columns": [
{ "data": "0" },
{ "data": "1" },
{ "data": "2" },
{ "data": "3" },
{ "data": "4" },
{ "data": "5" }
],
colReorder: {
order: [ 3,5,2,4,1,0 ]
},
} );
} );
Upvotes: 0
Views: 431
Reputation: 223
Be careful in using
colReorder: {
order: [ 3,5,2,4,1,0]
}
The order would be DATE-ID- SALARY-COUNTRY-POSITION-NAME 3 represents "3" in this JSON Object and so on and so forth
{
"0": "Tiger Nixon",
"1": "System Architect",
"2": "$320,800",
"3": "2011/04/25",
"4": "Edinburgh",
"5": "5421"
}
It's either you adjust the header or you adjust the colReorder or your columns, use this configuration for columns adjustments
"columns": [
{ "data": "0" },
{ "data": "1" },
{ "data": "4" },
{ "data": "5" },
{ "data": "3" },
{ "data": "2" }
]
Upvotes: 0