TableTools - add multiple lines into footer

TableTools - add multiple lines into footer

MisiuMisiu Posts: 68Questions: 4Answers: 2
edited October 2012 in Plug-ins
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]

Replies

  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    I've looked in oSettings and found nTFoot property and inside it there is rows property that holds number of rows.

    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!
  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    @Allan could You give this a try? :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There isn't a built in way of going this - but looping over the rows and cells (I suspect you want `cells` rather than `children` ) should do the business as you suggest. Not something I've tried myself, but I don't see a problem with it.

    Allan
  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    I'll try my solution and write about results.
    Maybe in future releases this could be build in-option to export multiline header and footer.
This discussion has been closed.