Sorting Text Not Sorting All Results
Sorting Text Not Sorting All Results
Hello, I have a datatable of about 1000 items. For some reason, 2-300 of these items seem to not be caught in the sorting mechanism. They show up in random orders, and then all of a sudden, all the other items show up sorted just fine. My table is filled via Ajax, and I am thinking that it might have to do with me adding data to the columns after the fact. Maybe I need to reinitialize the sort some how? Here is my code:
$('#customers').dataTable({
ajax: {
url: restURL,
dataSrc: ""
},
"columnDefs": [
{ "visible": false, "targets": [0] },
{ "className": 'never', "targets": [0]}
],
dom: "Tfrtip",
bInfo: false,
paging: false,
scrollY: 215,
order: [[ 2, "asc"]],
columns: [
{ "data": "Customer_ID" },
{"data":"Department",
"createdCell": function (td, cellData, rowData, row, col) {
if ($(td).html() === "") {
$(td).append(rowData['Cmpny_Name']);
}
}
},
{"data":"Name_Last",
"createdCell": function (td, cellData, rowData, row, col) { //Might need to change this to createdCell
if ($(td).html() !== "") {
$(td).append(', '+rowData['Name_First']);
} else {
$(td).append(rowData['Cmpny_Contact_Last']+', '+rowData['Cmpny_Contact_First']);
}
}
},
{ "data": "PI_Voice_Nmbr" },
{ "data": "PI_Email" },
{ "data": "Mail_Code" }
],
tableTools: {
sRowSelect: 'multi',
// sSelectedClass: ".selected",
// "sRowSelector": "td:not(:first-child)",
aButtons: [
"select_all",
"select_none",
{
"sExtends": "select",
"sButtonText": "More Info",
"fnClick": function () {
var salesOrderID = webOrderTable.cell(this, 0).data();
getSalesOrderData(salesOrderID);
lineItemData(salesOrderID);
}
}
]
}
});
Is there a way to try and reinitialize the sort afterwards and see if that might be the problem?
Thanks
David
This discussion has been closed.
Answers
Can you link to the page so I can take a look and see what is happening please?
I presume you are using the DataTables API to do that? If not then you are running into this FAQ.
Allan