read columns list from ajaxsource

read columns list from ajaxsource

msignoremsignore Posts: 2Questions: 0Answers: 0
edited August 2012 in General
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)

Thanks.

Replies

  • allanallan Posts: 63,395Questions: 1Answers: 10,451 Site admin
    edited August 2012
    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 ).

    Allan
  • msignoremsignore Posts: 2Questions: 0Answers: 0
    edited August 2012
    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...
This discussion has been closed.