Refresh the contents datatable on drop down change

Refresh the contents datatable on drop down change

usernanusernan Posts: 1Questions: 1Answers: 0

hello,

I have used jquery data table to render json values. and the columns are dynamic. whenever i change the drop down values the datatable won't get refreshed the previous values will retain and also count info will not change. and i will call this table(obj) on the ajax function. I have fnClearData(),fnDestroy();,clear(); it doesnot work for me. And I dont know where to use this fnClearTable();. If i use this function on button click i will get error like "TypeError: aoColumns[srcCol] is undefined"
here is the code

function table(obj) {

if (obj != null && obj.length > 0) {
    // var dynamicColumns = [];
    var i = 0;
    $.each(obj[0], function (key, val) {
        var objectt = { sTitle: key };
        // alert(objectt.toString());
        dynamicColumns[i] = objectt;
        i++;
    });

    var i = 0;
    $.each(obj, function (key, val) {
        var rowData = [];
        var j = 0;
        $.each(obj[i], function (key, val) {
            rowData[j] = val;
            j++;
        });
        rowDataSet[i] = rowData;

        i++;
    });


 $('#tbDetails').DataTable({
        dom: 'Bfrtip',
        "bDestroy": true,              
        "bretrieve": true,
        "bScrollCollapse": true,
        "bJQueryUI": true,
        "bPaginate": false,
        "sScrollY": "200px",
        "bInfo": true,
        "bFilter": true,
        "bSort": true,
        buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
        ],
        "aaData": rowDataSet,
        "aoColumns": dynamicColumns  //These are dynamically created columns present in JSON object.

    });

    $("#PlotResults").dialog('open');
}

}

Thanks in Advance

This discussion has been closed.