Save to PDF - Problem with bVisible: false columns
Save to PDF - Problem with bVisible: false columns
varmajp
Posts: 3Questions: 0Answers: 0
Tabletools function "fnCalcColRatios" not able to get the width of "bVisible: false" columns.
iWidth = aoCols[i].nTh.offsetWidth; - here width is 0 for "bVisible: false" columns
because of this pdf columns are overwritten/overlapped.
small hack solved my problem, but i want get the length from the table itself.
any solution ??
by assigning custom width we can avoid column overlapping.
if(iWidth == 0)
{
iWidth = 120;
}
iWidth = aoCols[i].nTh.offsetWidth; - here width is 0 for "bVisible: false" columns
because of this pdf columns are overwritten/overlapped.
small hack solved my problem, but i want get the length from the table itself.
any solution ??
by assigning custom width we can avoid column overlapping.
if(iWidth == 0)
{
iWidth = 120;
}
This discussion has been closed.
Replies
Modify the "fnCalcColRatios" function of TableTools.js script from:
[code]
"fnCalcColRatios": function (oConfig) {
var
aoCols = this.s.dt.aoColumns,
aColumnsInc = this._fnColumnTargets(oConfig.mColumns),
aColWidths = [],
iWidth = 0,
iTotal = 0,
i, iLen;
for (i = 0, iLen = aColumnsInc.length; i < iLen; i++) {
if (aColumnsInc[i]) {
iWidth = aoCols[i].nTh.offsetWidth;
iTotal += iWidth;
aColWidths.push(iWidth);
}
}
for (i = 0, iLen = aColWidths.length; i < iLen; i++) {
aColWidths[i] = aColWidths[i] / iTotal;
}
return aColWidths.join('\t');
}
[/code]
to:
[code]
"fnCalcColRatios": function (oConfig) {
var
aoCols = this.s.dt.aoColumns,
aColumnsInc = this._fnColumnTargets(oConfig.mColumns),
aColWidths = [],
iWidth = 0,
iTotal = 0,
i, iLen;
for (i = 0, iLen = aColumnsInc.length; i < iLen; i++) {
if (aColumnsInc[i]) {
iWidth = aoCols[i].nTh.offsetWidth;
/*-------- BEGIN NEW CODE ---------------------------------*/
if (iWidth == 0) {
var oTable = this.s.dt.oInstance;
oTable.fnSetColumnVis(i, true);
iWidth = aoCols[i].nTh.offsetWidth;
oTable.fnSetColumnVis(i, false);
}
/*-------- END NEW CODE -----------------------------------*/
iTotal += iWidth;
aColWidths.push(iWidth);
}
}
for (i = 0, iLen = aColWidths.length; i < iLen; i++) {
aColWidths[i] = aColWidths[i] / iTotal;
}
return aColWidths.join('\t');
}
[/code]
It works well . But what, if I don't want the invisible columns appear in the PDF or other out put forms.
Any suggestion?