Sorting problem with AJAX source

Sorting problem with AJAX source

morrtymorrty Posts: 29Questions: 6Answers: 0
edited January 2012 in General
EDIT: PLEASE IGNORE THIS POST (skip to post 2) - I have solved this issue by using the "sType": "string" option. However, as outlined in post #2, I still have a problem in that I'm not sure how to pass an HTML link using an AJAX source with json array of objects.

I was originally using a DOM source but when my tables started having 3k+ rows, DataTables became too slow. Today I switched over to an AJAX source using a JSON array of objects. It loads much faster and I'm happy with that. However, it seems to be doign weird things when it comes to sorting my columns.

My first column specifically, it is data in the following format: XX00000 (two letter prefix with up to 5 number suffix). It seems to be sorting based on the number and ignoring the two letter prefix altogether.

Here is my initialization:

[code]
$( '#dt-contracts' ).dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bDeferRender": true,
"bAutoWidth": false,
"iDisplayLength": 25,
"aaSorting": [[0, 'asc']],
"bProcessing": true,
"sAjaxSource": '/json/contracts.json.php',
"aoColumns": [
{ "mDataProp": "contract" },
{ "mDataProp": "number" },
{ "mDataProp": "name" },
{ "mDataProp": "commodity" },
{ "mDataProp": "grade" }
],
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "/js/datatables/extras/tabletools/swf/copy_cvs_xls.swf",
"aButtons": [
"print",
{
"sExtends": "text",
"sButtonText": "Add Contract",
"fnClick": function () {
location.href = '?add=contract';
}
}
]
}
} );
[/code]

Sorting worked when I was using DOM source, what is going on with the AJAX source to cause this?

Replies

  • morrtymorrty Posts: 29Questions: 6Answers: 0
    Actually, I have a second problem now, when using DOM, I made my first column a link. Now I'm not sure how to do that. Do I put the HTML in the array before json encoding it?
This discussion has been closed.