Generate columns using fnServerData

Generate columns using fnServerData

sosisi4sosisi4 Posts: 3Questions: 3Answers: 0
edited February 2015 in Free community support

I am trying to add/create (whatever you want to call) columns based on data I am getting in fnServerData. Basically, I have an array and I am pushing values in fnServerData. Then I am trying to assign this array to aoColumns. I am guessing it renders options at the same time so data change on my array does not effect aoColumns operation. Below is the code snippet;

var headerArray = [];
headerArray.push({"sTitle": "Column1"}, {"sTitle": "Column2"});

$("#table").dataTable({
    ...
    "fnServerData": function (sSource, aoData, fnCallback) {
        ....
        headerArray.push(someData);
        ....
    },
    "aoColumns" : headerArray
});

It only generates Column1 and Column2. So do you have any ideas about handling this?

This discussion has been closed.