Hi!
Can DataTables read columns (names) list from ajaxSource? I mean I define columns in my php file and pass them with data, and dataTables parses them and create the table (full dynamically)
Currently no - that is something I will be looking at making much easier in 1.10.
*Edit* having said that - it is perfectly possible to make an Ajax call yourself and then feed the result to DataTables, which can include the column titles ( sTitle ).
Thanks allan,
I changed my code to this:
[code]
$.ajax( {
dataType: 'json',
type: 'POST',
url: 'scripts/_server_processing.php',
success: function(json){
$('#example').dataTable({
bDestroy: true,
bProcessing: true,
aaData: json.aaData,
aoColumns: json.aoColumns
});
}
} );
[/code]
It works well, but when I want to refresh table data, and call this function again, it redraw the table and REMOVE SORTING OPTION.. but I want to keep user options...
Replies
*Edit* having said that - it is perfectly possible to make an Ajax call yourself and then feed the result to DataTables, which can include the column titles ( sTitle ).
Allan
I changed my code to this:
[code]
$.ajax( {
dataType: 'json',
type: 'POST',
url: 'scripts/_server_processing.php',
success: function(json){
$('#example').dataTable({
bDestroy: true,
bProcessing: true,
aaData: json.aaData,
aoColumns: json.aoColumns
});
}
} );
[/code]
It works well, but when I want to refresh table data, and call this function again, it redraw the table and REMOVE SORTING OPTION.. but I want to keep user options...