Rerendering of Column Titles
Rerendering of Column Titles
Hey @all,
i want to add columns dynamically to the data table depending on a json result, which is requested from a server. I'm using the fnReloadAjax PlugIn and i have some problems to solve this task.
Is there a function which renders not only the data part of the table but also the "table header". I mean is there a function which rerenders the column names?
This part is resetting the aoColumns array an reinitializes it:
var aColumns = that.oApi._fnGetObjectDataFn("aoColumns")(json);
oSettings.aoColumns = [];
for ( var i = 0; i < aColumns.length; i++) {
that.oApi._fnAddColumn(oSettings, i);
oSettings.aoColumns[i].sTitle = aColumns[i].sTitle;
}
This part should rerender the table. But only the data part is rerendered:
that._fnBuildHead(oSettings);
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that._fnDrawHead(oSettings, oSettings.aoHeader);
that._fnReDraw(oSettings);
Can anyone help me?
Best regards,
J0sh
i want to add columns dynamically to the data table depending on a json result, which is requested from a server. I'm using the fnReloadAjax PlugIn and i have some problems to solve this task.
Is there a function which renders not only the data part of the table but also the "table header". I mean is there a function which rerenders the column names?
This part is resetting the aoColumns array an reinitializes it:
var aColumns = that.oApi._fnGetObjectDataFn("aoColumns")(json);
oSettings.aoColumns = [];
for ( var i = 0; i < aColumns.length; i++) {
that.oApi._fnAddColumn(oSettings, i);
oSettings.aoColumns[i].sTitle = aColumns[i].sTitle;
}
This part should rerender the table. But only the data part is rerendered:
that._fnBuildHead(oSettings);
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that._fnDrawHead(oSettings, oSettings.aoHeader);
that._fnReDraw(oSettings);
Can anyone help me?
Best regards,
J0sh
This discussion has been closed.
Replies
If your column count is always going to be identical, then you can just use standard DOM methods to write the contents of the header cells - the only time DataTables writes to then is on initialisation, and even then only if required. Again this could be wrapper up into an API plug-in :-)
Allan