Variable Columns Sorting not working on other then string datatypes
Variable Columns Sorting not working on other then string datatypes

Hi,
Our Datatables Initialization has "aoColumns": resultColumns where resultColumns can vary depending on selection
and the table is build dynamically on the fly. I am not able to assign sorting or sTypes on individual columns because they can vary each time depending on the order of selection. DataTable is not recognizing the datatypes depending on the data it only sorts by string.
Please see the complete defnition of init table
"[Code]
resultSetTable = $('#tblResults').dataTable({
"iDisplayLength": 10,
"bLengthChange": true,
"aLengthMenu": [[10, 25, 50, 100, 10000], [10, 25, 50, 100, "Show All"]],
"sDom": 'T<"clear">lfrtip',
"oTableTools": { "sSwfPath": "Styles/swf/copy_cvs_xls_pdf.swf" },
"bJQueryUI": true,
"aoColumns": resultColumns,
"bFilter": true,
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": true,
"bStateSave": false,
"sAjaxSource": globalServiceUrl + 'GetSortReport',
"sScrollX": "100%",
"sScrollY": 400,
"sScrollXInner": "110%",
"sScrollYInner": "110%",
"bScrollCollapse": true,
"aoColumnDefs": [ { "sType": "Date", "aTargets": [ 1 ] } ],
"fnServerData": function (sSource, aoData, fnCallback) {
var sEcho, iDisplayStart, iDisplayLength, sSearch, iSortColIndex, sSortColDir
for (var index = 0; index < aoData.length; index++) {
if (aoData[index].name == "sEcho") reportParam.sEcho = aoData[index].value;
if (aoData[index].name == "iDisplayStart") reportParam.iDisplayStart = aoData[index].value;
if (aoData[index].name == "iDisplayLength") reportParam.iDisplayLength = aoData[index].value;
if (aoData[index].name == "sSearch") reportParam.sSearch = aoData[index].value;
if (aoData[index].name == "iSortCol_0") reportParam.iSortColIndex = aoData[index].value;
if (aoData[index].name == "sSortDir_0") reportParam.sSortColDir = aoData[index].value;
} [/Code]"
Any ideas of how to acheive this functionality.
Our Datatables Initialization has "aoColumns": resultColumns where resultColumns can vary depending on selection
and the table is build dynamically on the fly. I am not able to assign sorting or sTypes on individual columns because they can vary each time depending on the order of selection. DataTable is not recognizing the datatypes depending on the data it only sorts by string.
Please see the complete defnition of init table
"[Code]
resultSetTable = $('#tblResults').dataTable({
"iDisplayLength": 10,
"bLengthChange": true,
"aLengthMenu": [[10, 25, 50, 100, 10000], [10, 25, 50, 100, "Show All"]],
"sDom": 'T<"clear">lfrtip',
"oTableTools": { "sSwfPath": "Styles/swf/copy_cvs_xls_pdf.swf" },
"bJQueryUI": true,
"aoColumns": resultColumns,
"bFilter": true,
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": true,
"bStateSave": false,
"sAjaxSource": globalServiceUrl + 'GetSortReport',
"sScrollX": "100%",
"sScrollY": 400,
"sScrollXInner": "110%",
"sScrollYInner": "110%",
"bScrollCollapse": true,
"aoColumnDefs": [ { "sType": "Date", "aTargets": [ 1 ] } ],
"fnServerData": function (sSource, aoData, fnCallback) {
var sEcho, iDisplayStart, iDisplayLength, sSearch, iSortColIndex, sSortColDir
for (var index = 0; index < aoData.length; index++) {
if (aoData[index].name == "sEcho") reportParam.sEcho = aoData[index].value;
if (aoData[index].name == "iDisplayStart") reportParam.iDisplayStart = aoData[index].value;
if (aoData[index].name == "iDisplayLength") reportParam.iDisplayLength = aoData[index].value;
if (aoData[index].name == "sSearch") reportParam.sSearch = aoData[index].value;
if (aoData[index].name == "iSortCol_0") reportParam.iSortColIndex = aoData[index].value;
if (aoData[index].name == "sSortDir_0") reportParam.sSortColDir = aoData[index].value;
} [/Code]"
Any ideas of how to acheive this functionality.
This discussion has been closed.
Replies
Allan
That was indeed correct the issue is now fixed.
Thanks again