Records Not Appearing In Order in DataTables
Records Not Appearing In Order in DataTables
tinker1123
Posts: 22Questions: 0Answers: 0
Hi,
I'm using AJAX to send data to DataTables, without server side processing.
My logs show that the JSON leaving the server is in order, but the order gets scrambled by the time it is displayed in DataTables.
This is the case both with IE 8 and FF 16.01.
Does DataTables by default sort on a particular column and if so is there a way to turn that off?
Here is my table code:
[code]
//Staff VECI for 540733
$(document).ready(function() {
$('#540733_staff_veci_table').dataTable( {
"bPaginate": false,
"sScrollY": "250px",
"bScrollCollapse": true,
"bFilter": false,
"bServerSide": false,
"sServerMethod": "POST",
"sAjaxSource": "/nsd/staffvecitable",
"aoColumns": aoColumns,
"bProcessing": true,
"bDeferRender": true,
"fnServerParams": function ( aoData ) { aoData.push( { "name": "person_id", "value": "540733" } );}
} );
} );
[/code]
Here are the first 3 rows/records in my JSON string, in alphabetical order by last name, first name, middle name:
[code]
{
"aaData" : [ {
"person_id" : "3304",
"fullname" : "Campbell, Billy J",
"email_address" : "billy.j.campbell@acme.com",
"emergency_email_address" : "buffet@margaritaville.com",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
"person_id" : "61885",
"fullname" : "Gao, Paul",
"noaa_email_address" : "someotherstupid.email@noaa.gov",
"emergency_email_address" : "",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
"person_id" : "661935",
"fullname" : "Test0009, Jan0009",
"noaa_email_address" : "",
"emergency_email_address" : "",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
[/code]
However in Datatables the first 3 names are
Cambell
Vargas
Gao
not alphabetical order or reversed alphabetical order.
Any ideas on what I can look at it as the source of the problem?
Thanks much in advance
Steve
I'm using AJAX to send data to DataTables, without server side processing.
My logs show that the JSON leaving the server is in order, but the order gets scrambled by the time it is displayed in DataTables.
This is the case both with IE 8 and FF 16.01.
Does DataTables by default sort on a particular column and if so is there a way to turn that off?
Here is my table code:
[code]
//Staff VECI for 540733
$(document).ready(function() {
$('#540733_staff_veci_table').dataTable( {
"bPaginate": false,
"sScrollY": "250px",
"bScrollCollapse": true,
"bFilter": false,
"bServerSide": false,
"sServerMethod": "POST",
"sAjaxSource": "/nsd/staffvecitable",
"aoColumns": aoColumns,
"bProcessing": true,
"bDeferRender": true,
"fnServerParams": function ( aoData ) { aoData.push( { "name": "person_id", "value": "540733" } );}
} );
} );
[/code]
Here are the first 3 rows/records in my JSON string, in alphabetical order by last name, first name, middle name:
[code]
{
"aaData" : [ {
"person_id" : "3304",
"fullname" : "Campbell, Billy J",
"email_address" : "billy.j.campbell@acme.com",
"emergency_email_address" : "buffet@margaritaville.com",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
"person_id" : "61885",
"fullname" : "Gao, Paul",
"noaa_email_address" : "someotherstupid.email@noaa.gov",
"emergency_email_address" : "",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
"person_id" : "661935",
"fullname" : "Test0009, Jan0009",
"noaa_email_address" : "",
"emergency_email_address" : "",
"emergency_cell" : "",
"emergency_sms" : ""
}, {
[/code]
However in Datatables the first 3 names are
Cambell
Vargas
Gao
not alphabetical order or reversed alphabetical order.
Any ideas on what I can look at it as the source of the problem?
Thanks much in advance
Steve
This discussion has been closed.
Replies
[code]
//Staff VECI for 540733
$(document).ready(function() {
$('#540733_staff_veci_table').dataTable( {
"bPaginate": false,
"sScrollY": "250px",
"bScrollCollapse": true,
"bFilter": false,
"bServerSide": false,
"sServerMethod": "POST",
"sAjaxSource": "/nsd/staffvecitable",
"aoColumns": aoColumns,
"bProcessing": true,
"bDeferRender": true,
"bSort": false,
"fnServerParams": function ( aoData ) { aoData.push( { "name": "person_id", "value": "540733" } );}
} );
} );
[/code]
[code]
(document).ready(function() {
var oTable = $('#540733_staff_veci_table'}_staff_veci_table').dataTable();
// Sort immediately with column1
oTable.fnSort( [[1,'asc']] );
);
[/code]
I'm new to and find function callback syntax confusing, is there a way to tuck this code into the table initialization?