TableTools not sorting on Print View
TableTools not sorting on Print View
ljrivera
Posts: 11Questions: 0Answers: 0
Hello,
I am trying to use Tabletools and everything works perfectly but the sorting of columns on while on print mode.
I dont know if this has anything to do with the fact that the table is really wide and normally would have sScrollX enabled.
So i have been playing around on debug mode and i notice something.
At the beginning of _fnPrintStart , _fnPrintHideNodes is called. While on debug mode, i noticed that this removed the table header. If i modified the code so that it didnt remove this header, then this headers sorting functions worked, however this header was too short and did not contain all the data.
.
Later on the header is reinserted on the _fnPrintScrollStart function, however this new header does not allow sorting.
Is there a initialization variable i missed that i should have enabled to turn the sorting on??
Thanks for your time and help,
L
I am trying to use Tabletools and everything works perfectly but the sorting of columns on while on print mode.
I dont know if this has anything to do with the fact that the table is really wide and normally would have sScrollX enabled.
So i have been playing around on debug mode and i notice something.
At the beginning of _fnPrintStart , _fnPrintHideNodes is called. While on debug mode, i noticed that this removed the table header. If i modified the code so that it didnt remove this header, then this headers sorting functions worked, however this header was too short and did not contain all the data.
.
Later on the header is reinserted on the _fnPrintScrollStart function, however this new header does not allow sorting.
Is there a initialization variable i missed that i should have enabled to turn the sorting on??
Thanks for your time and help,
L
This discussion has been closed.
Replies
EDIT:
after removing
sScrollX and sScrollXInner, sorting works on print view, but i kinda need these enabled
[code] oSetDT.nScrollHead.style.width = $(oSetDT.nTable).outerWidth()+"px";[/code]
now it sorta works, sorting works but the widths on the header re-size as soon as i sort by anything and the there is a mismatch with the table cols.
Allan can you point me on the right direction? Thanks
Allan
Yes, you are right on the example it does remain. The only problem occurs when sScrollX is enabled (if i disable it, it works as expected).
When _fnPrintStart is called the header is removed on
[code]this._fnPrintHideNodes( oSetDT.nTable );[/code]
latter on this peice of code is called
[code]/* Adjust the display for scrolling which might be done by DataTables */
if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
{
this._fnPrintScrollStart( oSetDT );
// If the table redraws while in print view, the DataTables scrolling
// setup would hide the header, so we need to readd it on draw
$(this.s.dt.nTable).bind('draw.DTTT_Print', function () {
that._fnPrintScrollStart( oSetDT );
} );
}[/code]
Then the header is finally readded on _fnPrintScrollStart.
[code]/* Copy the header in the thead in the body table, this way we show one single table when
* in print view. Note that this section of code is more or less verbatim from DT 1.7.0
*/
var nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
oSetDT.nTable.removeChild( nTheadSize[0] );
}
if ( oSetDT.nTFoot !== null )
{
var nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
oSetDT.nTable.removeChild( nTfootSize[0] );
}
}
nTheadSize = oSetDT.nTHead.cloneNode(true);
oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] ); //Header reinserted here!!
[/code].
This new header looks fine but it wont allow sorting. It might take me some time but ill work on giving you an example. Thanks again for your help.
Sorry its not the prettiest but it will do for now
http://jsfiddle.net/aGGtb/11/embedded/result/
As you can see the sorting is not working on the print page.
Thanks again for your help
Allan
[code]/*
* The HTML structure that we want to generate in this function is:
* div - nScroller
* div - nScrollHead
* div - nScrollHeadInner
* table - nScrollHeadTable
* thead - nThead
* div - nScrollBody
* table - oSettings.nTable
* thead - nTheadSize
* tbody - nTbody
* div - nScrollFoot
* div - nScrollFootInner
* table - nScrollFootTable
* tfoot - nTfoot
*/
[/code]
and the second one is, can you explain a little bit more how sScrollXInner inner works? I read that it forces the scrolling to use more space, but if i have sScrollX enabled and remove the Xinner, my table wont have a scrollbar on the bottom dispite having a large table.
Similarly if i add it, it will work fine with some tables, but the scrollbar will act funky with larger tables with more cols. Right now i wrote a workaround that sets up the sScrollXinner depending on the total column count but it would be nice to know a bit more how this worked.
Thanks again for you time and help,
L