TableTools not sorting on Print View

TableTools not sorting on Print View

ljriveraljrivera Posts: 11Questions: 0Answers: 0
edited January 2013 in TableTools
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

Replies

  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    edited January 2013
    I believe that the listners for the sort buttons might not be properly set when the complete header is reinserted. I will further investigate.

    EDIT:
    after removing
    sScrollX and sScrollXInner, sorting works on print view, but i kinda need these enabled
  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    instead, of letting it it remove and reinsert the header, kept the old one and re sized it with this code
    [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
  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    I used the css to force the table to resize correctly but i think there is a bug in the code.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Can you link to a test case please? As you can see here, the header is retained on this table: http://datatables.net/extras/tabletools/ . So I need to know when it is removed.

    Allan
  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    edited January 2013
    Hey allan thanks for your help ill try to put my code on a public facing site so you can see the example.
    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.
  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    edited January 2013
    Hey allan here is the sample test case,
    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
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Thanks for the link to the test case. I'm not entirely sure what the problem is off the top of my head, but it does look like a bug. I'll try to make some time to look into this next week.

    Allan
  • ljriveraljrivera Posts: 11Questions: 0Answers: 0
    Thanks for looking into it allan, I have two questions for you. I was looking into the source and i am having trouble understanding something. Why is it that when there is scrolling involved, you split up the header from the body?
    [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
This discussion has been closed.