TableTools - add multiple lines into footer
TableTools - add multiple lines into footer
I have multiline footer in my table. Right now TableTools export one line.
I've searched code and found this block:
[code]
/*
* Footer
*/
if (oConfig.bFooter && dt.nTFoot !== null) {
aRow = [];
for (i = 0, iLen = dt.aoColumns.length; i < iLen; i++) {
if (aColumnsInc[i] && dt.aoColumns[i].nTf !== null) {
sLoopData = dt.aoColumns[i].nTf.innerHTML.replace(/\n/g, " ")
.replace(/<.*?>/g, "");
sLoopData = this._fnHtmlDecode(sLoopData);
aRow.push(this._fnBoundData(sLoopData, oConfig.sFieldBoundary, regex));
}
}
aData.push(aRow.join(oConfig.sFieldSeperator));
}
[/code]
is it possible to modify this part so that exported table will have all lines of footer?
My table looks like this:
[code]
Name
Column1
Column2
Column3
%
Delete
Sum
Avg
[/code]
I've searched code and found this block:
[code]
/*
* Footer
*/
if (oConfig.bFooter && dt.nTFoot !== null) {
aRow = [];
for (i = 0, iLen = dt.aoColumns.length; i < iLen; i++) {
if (aColumnsInc[i] && dt.aoColumns[i].nTf !== null) {
sLoopData = dt.aoColumns[i].nTf.innerHTML.replace(/\n/g, " ")
.replace(/<.*?>/g, "");
sLoopData = this._fnHtmlDecode(sLoopData);
aRow.push(this._fnBoundData(sLoopData, oConfig.sFieldBoundary, regex));
}
}
aData.push(aRow.join(oConfig.sFieldSeperator));
}
[/code]
is it possible to modify this part so that exported table will have all lines of footer?
My table looks like this:
[code]
Name
Column1
Column2
Column3
%
Delete
Sum
Avg
[/code]
This discussion has been closed.
Replies
So above code should look like so:
[code]
if (oConfig.bFooter && dt.nTFoot !== null) {
//another loop
for (i = 0; rowCount = dt.nTFoot.rows.length; i < rowCount; i++) {
aRow = []; //clear row data
for (j = 0, iLen = dt.aoColumns.length; j < iLen; j++) {
if (aColumnsInc[j]) {
if (dt.nTFoot.rows[i].children[j] !== null) {
sLoopData = dt.nTFoot.rows[i].children[j].innerHTML.replace(/\n/g, " ").replace(/<.*?>/g, "");
sLoopData = this._fnHtmlDecode(sLoopData);
aRow.push(this._fnBoundData(sLoopData, oConfig.sFieldBoundary, regex));
} else {
//here we should add empty element to row so every row has the same length
}
}
}
aData.push(aRow.join(oConfig.sFieldSeperator));
}
}
[/code]
I didn't have chance to test this, but I think that this will have one big issue: how to iterate footer cells with aColumnsInc, so that we can include column 1,3,5?
I found another question asking for multi-row header, I think that using my approach this can be done!
Allan
Maybe in future releases this could be build in-option to export multiline header and footer.