FlashJunior: Moved question about state saving
FlashJunior: Moved question about state saving
Hi.
i'm using dataTables js in a small cms on different places.
the main settings are in a js and all the sorting stuff on data tag.
here an example:
Tables/html:
[code]
Text
Nummer
Datum
Rendering engine
Browser
Platform(s)
Engine version
CSS grade
[/code]
JS:
[code]
$(document).ready(function() {
$('.datatable_display').each(function(){
var table = $(this);
var table_d = table.data("datatable");
//init table sorting
var aoColumns = [];
var aaSorting = [];
$('thead th', table).each(function(){
var obj = $(this);
var obj_d = obj.data("datatable");
if(obj_d && obj_d.sort){
aaSorting.push([obj.index(),obj_d.sort]);
}
if(obj_d && obj_d.type){
aoColumns.push({"sType": obj_d.type});
}else{
aoColumns.push(null);
}
});
//init table settings
var table_s = {}
table_s.bJQueryUI = true;
table_s.bProcessing = true;
table_s.bDeferRender = true;
table_s.sPaginationType = "full_numbers";
table_s.aaSorting = aaSorting;
table_s.aoColumns = aoColumns;
if(table_d && table_d.source){
table_s.sAjaxSource = table_d.source;
}
if(table_d && table_d.statesave){
table_s.bStateSave = table_d.statesave;
}
table.dataTable(table_s);
});
});
[/code]
not very sexy.. but it works. is there a better way to do that?
i'm using dataTables js in a small cms on different places.
the main settings are in a js and all the sorting stuff on data tag.
here an example:
Tables/html:
[code]
Text
Nummer
Datum
Rendering engine
Browser
Platform(s)
Engine version
CSS grade
[/code]
JS:
[code]
$(document).ready(function() {
$('.datatable_display').each(function(){
var table = $(this);
var table_d = table.data("datatable");
//init table sorting
var aoColumns = [];
var aaSorting = [];
$('thead th', table).each(function(){
var obj = $(this);
var obj_d = obj.data("datatable");
if(obj_d && obj_d.sort){
aaSorting.push([obj.index(),obj_d.sort]);
}
if(obj_d && obj_d.type){
aoColumns.push({"sType": obj_d.type});
}else{
aoColumns.push(null);
}
});
//init table settings
var table_s = {}
table_s.bJQueryUI = true;
table_s.bProcessing = true;
table_s.bDeferRender = true;
table_s.sPaginationType = "full_numbers";
table_s.aaSorting = aaSorting;
table_s.aoColumns = aoColumns;
if(table_d && table_d.source){
table_s.sAjaxSource = table_d.source;
}
if(table_d && table_d.statesave){
table_s.bStateSave = table_d.statesave;
}
table.dataTable(table_s);
});
});
[/code]
not very sexy.. but it works. is there a better way to do that?
This discussion has been closed.