fnSort after render
fnSort after render
frankthetank
Posts: 3Questions: 0Answers: 0
Hi,
I'm using this great plugin but I have a question.
I'm generating the dataTables using a class (dataTable), so that any Ajax page loaded is going to have the html table converted automaticly, with the same parameters.
For a specific page, I would like to sort by a specific column using fnSort, but how to I get the dataTable without regenerating it ?
Main page ---> Ajax load (callback generate the dataTable with parameters).
General dataTable code :
[code]
$(".dataTable").dataTable({
"bRetrieve": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange":false,
"bPaginate": false,
"sScrollY": hauteur,
"oLanguage": {
"sUrl":"scripts/dataTableFR.js"
}
});
[/code]
Code on the page I want to execute (loaded via Ajax)
[code]
$(".dataTable").dataTable().fnSort( [ [4,'desc'] ] );
[/code]
It's working, but it's not keeping the original values of the dataTable. I do not want to duplicate code.
SHORT QUESTION : Is it possible to reference and already created dataTable (without saving a reference on a variable) ?
If not, I will simply recreate the dataTable by calling a method to get the same parameters.
Thanks !
I'm using this great plugin but I have a question.
I'm generating the dataTables using a class (dataTable), so that any Ajax page loaded is going to have the html table converted automaticly, with the same parameters.
For a specific page, I would like to sort by a specific column using fnSort, but how to I get the dataTable without regenerating it ?
Main page ---> Ajax load (callback generate the dataTable with parameters).
General dataTable code :
[code]
$(".dataTable").dataTable({
"bRetrieve": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange":false,
"bPaginate": false,
"sScrollY": hauteur,
"oLanguage": {
"sUrl":"scripts/dataTableFR.js"
}
});
[/code]
Code on the page I want to execute (loaded via Ajax)
[code]
$(".dataTable").dataTable().fnSort( [ [4,'desc'] ] );
[/code]
It's working, but it's not keeping the original values of the dataTable. I do not want to duplicate code.
SHORT QUESTION : Is it possible to reference and already created dataTable (without saving a reference on a variable) ?
If not, I will simply recreate the dataTable by calling a method to get the same parameters.
Thanks !
This discussion has been closed.