Custom sort problem
Custom sort problem
tomas209
Posts: 1Questions: 0Answers: 0
Hi,
I'm experiencing a problem when using custom sort definition. I define custom sorting for one table column:
[code]
"aoColumns": [
{ sWidth: "20%", "sType": 'detail_date' },
{ sWidth: "10%" },
{ sWidth: "45%" },
{ sWidth: "25%" }
]
[/code]
and callback sorting function as follows:
[code]
jQuery.fn.dataTableExt.oSort['detail_date-asc'] = function(x, y) ...
jQuery.fn.dataTableExt.oSort['detail_date-desc'] = function(x, y) ...
[/code]
I switched state saving on. So part of options defunitions is as fllows:
[code]
...
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"bStateSave": true,
"sPaginationType": "four_button",
"aaSorting": [],
...
[/code]
When I first load the page, sorting works fine on every column. But when I have first column sorted and refresh page via F5, sorting on all columns stops working. In IE javascript error is shown: "Object doesn't support this property or method", referencing to jQuery.datatables.js, to code
[code]
iTest = oSort[ iDataType+"-"+aaSort[i][1] ](
aoData[a]._aData[iDataSort],
aoData[b]._aData[iDataSort]
);
[/code]
Also, I'd like to have default sorting on the first column (ie the one with custom sorting), but when I use
[code]
"aaSorting": [[0, "asc"]],
[/code]
the js error is thrown right at the page load.
Any help greatly appreciated.
And thanks for this great plugin and your effort, anyway.
I'm experiencing a problem when using custom sort definition. I define custom sorting for one table column:
[code]
"aoColumns": [
{ sWidth: "20%", "sType": 'detail_date' },
{ sWidth: "10%" },
{ sWidth: "45%" },
{ sWidth: "25%" }
]
[/code]
and callback sorting function as follows:
[code]
jQuery.fn.dataTableExt.oSort['detail_date-asc'] = function(x, y) ...
jQuery.fn.dataTableExt.oSort['detail_date-desc'] = function(x, y) ...
[/code]
I switched state saving on. So part of options defunitions is as fllows:
[code]
...
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"bStateSave": true,
"sPaginationType": "four_button",
"aaSorting": [],
...
[/code]
When I first load the page, sorting works fine on every column. But when I have first column sorted and refresh page via F5, sorting on all columns stops working. In IE javascript error is shown: "Object doesn't support this property or method", referencing to jQuery.datatables.js, to code
[code]
iTest = oSort[ iDataType+"-"+aaSort[i][1] ](
aoData[a]._aData[iDataSort],
aoData[b]._aData[iDataSort]
);
[/code]
Also, I'd like to have default sorting on the first column (ie the one with custom sorting), but when I use
[code]
"aaSorting": [[0, "asc"]],
[/code]
the js error is thrown right at the page load.
Any help greatly appreciated.
And thanks for this great plugin and your effort, anyway.
This discussion has been closed.
Replies
> include the plug-in's code in the Javascript available for your page, after you load the DataTables library, but before you initialise the DataTable
I'll look at ways of making this clearer in future.
Regards,
Allan