How fill columns dynamically in DataTables.
How fill columns dynamically in DataTables.
I'm new in this domain.
I want to put values in columns of my DataTables.
The first column must have nothing ("") and then I have an array that I have to fill in the wake of nothing.
Here my javascript code :
function fillDataTable11(data, allyearstat11) {
if ($("#table_statistic_11").css("visibility") == "hidden")
$("#table_statistic_11").css("visibility", "visible");
$('#table_statistic_11').dataTable({
'aaData': data,
'aoColumns': [
{ "sTitle": "", "sCellType": "th", "fnCreatedCell": function (cell) { cell.scope = 'row'; } },
{ "sTitle": allyearstat11[0] },
{ "sTitle": allyearstat11[1] },
{ "sTitle": allyearstat11[2] },
{ "sTitle": allyearstat11[3] },
{ "sTitle": allyearstat11[4] },
{ "sTitle": allyearstat11[5] },
{ "sTitle": allyearstat11[6] },
{ "sTitle": allyearstat11[7] },
{ "sTitle": allyearstat11[8] },
{ "sTitle": allyearstat11[9] },
{ "sTitle": allyearstat11[10] },
{ "sTitle": allyearstat11[11] },
{ "sTitle": allyearstat11[12] },
{ "sTitle": allyearstat11[13] },
{ "sTitle": allyearstat11[14] },
{ "sTitle": allyearstat11[15] },
{ "sTitle": allyearstat11[16] },
{ "sTitle": allyearstat11[17] },
{ "sTitle": allyearstat11[18] },
{ "sTitle": allyearstat11[19] },
{ "sTitle": allyearstat11[20] }
],
"iDisplayLength": 12,
"bJQueryUI": true,
"bDestroy": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false
});
}
How do I do?
Thanks.
I want to put values in columns of my DataTables.
The first column must have nothing ("") and then I have an array that I have to fill in the wake of nothing.
Here my javascript code :
function fillDataTable11(data, allyearstat11) {
if ($("#table_statistic_11").css("visibility") == "hidden")
$("#table_statistic_11").css("visibility", "visible");
$('#table_statistic_11').dataTable({
'aaData': data,
'aoColumns': [
{ "sTitle": "", "sCellType": "th", "fnCreatedCell": function (cell) { cell.scope = 'row'; } },
{ "sTitle": allyearstat11[0] },
{ "sTitle": allyearstat11[1] },
{ "sTitle": allyearstat11[2] },
{ "sTitle": allyearstat11[3] },
{ "sTitle": allyearstat11[4] },
{ "sTitle": allyearstat11[5] },
{ "sTitle": allyearstat11[6] },
{ "sTitle": allyearstat11[7] },
{ "sTitle": allyearstat11[8] },
{ "sTitle": allyearstat11[9] },
{ "sTitle": allyearstat11[10] },
{ "sTitle": allyearstat11[11] },
{ "sTitle": allyearstat11[12] },
{ "sTitle": allyearstat11[13] },
{ "sTitle": allyearstat11[14] },
{ "sTitle": allyearstat11[15] },
{ "sTitle": allyearstat11[16] },
{ "sTitle": allyearstat11[17] },
{ "sTitle": allyearstat11[18] },
{ "sTitle": allyearstat11[19] },
{ "sTitle": allyearstat11[20] }
],
"iDisplayLength": 12,
"bJQueryUI": true,
"bDestroy": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false
});
}
How do I do?
Thanks.
This discussion has been closed.
Replies
var tabTitleColumn = [];
for (var i = 0; i < allyearstat11.length; i++) {
tabTitleColumn.push({
" sTitle": allyearstat11[i],
});
};
And after :
'aoColumns': tabTitleColumn