Scroller Issue: to/from numbers wrong

Scroller Issue: to/from numbers wrong

tacman1123tacman1123 Posts: 198Questions: 46Answers: 1
edited June 2011 in Plug-ins
http://www.surveyrepository.com/phenx/domains

The table itself is working, but it's only 21 rows, yet the numbers at the bottom say

Showing 16 to 32 of 21 entries

Any idea what I'm doing wrong?

Thx,

Tac

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Interesting one - I'm reasonably certain that it is due to the styling difference between the uninitialised table and the initialised table (nice styling btw!). In the "raw" state the row heights are fairly small, which I think scroller is using, while in the styled table they are a good bit taller.

    As an experiment could you try something like this:

    [code]
    "fnInitComplete": function (o) {
    o.oScroller._fnCalcRowHeight();
    this.fnDraw();
    }
    [/code]

    You'll need the Scroller 1.0.1.dev nightly from the downloads page to get that to work. It will just recalculate the row height and then redraw the table with the new information.

    Thanks,
    Allan
  • tacman1123tacman1123 Posts: 198Questions: 46Answers: 1
    Hi, Allan, 1.8.1 (and the latest Scroller) has (mostly) fixed it, the end number is now right:

    http://www.surveyrepository.com/phenx/domains

    BUT the numbers that it shows on the page are off, it says "Showing 1-16", but in fact it's only 1-11. The numbers aren't that important, what I'd actually prefer to see is the start and end sort column, so something like "Showing Alcohol to Nutrition", but that's not really even that important. That might be more important when moving the scoller, but I realize that's a lot more data than the index.

    Anyway, this is great, thanks!

    Tac
  • kciveykcivey Posts: 3Questions: 0Answers: 0
    The problem is that _fnCalcRowHeight() creates the test table at the end of the document body rather than in the environment the actual table will eventually be in. We have CSS (some of it inherited from a theme written by someone else) that uses the containing div with class "dataTables_scrollBody" to set the table style. But the test table created by _fnCalcRowHeight() doesn't have that div and so doesn't have the same row height as the actual table.

    Modifying the code as follows seems to work:
    [code]
    --- media/js/Scroller.js (revision 11519)
    +++ media/js/Scroller.js (working copy)
    @@ -525,6 +525,7 @@
    "_fnCalcRowHeight": function ()
    {
    var
    + nDiv = document.createElement('div'),
    nTable = this.s.dt.nTable.cloneNode( false ),
    nBody = document.createElement( 'tbody' ),
    nTr = document.createElement('tr'),
    @@ -534,9 +535,11 @@
    nTr.appendChild( nTd );
    nBody.appendChild( nTr );
    nTable.appendChild( nBody );
    - document.body.appendChild( nTable );
    + nDiv.className = this.s.dt.oClasses.sScrollBody;
    + nDiv.appendChild( nTable );
    + document.body.appendChild( nDiv );
    this.s.rowHeight = $(nTr).height();
    - document.body.removeChild( nTable );
    + document.body.removeChild( nDiv );
    },

    [/code]

    (I work with Tac.)
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Nice one! Thanks very much for that kcivey :-). I've just merged in your github pull request for this - and it will be in the next Scroller release.

    Regards,
    Allan
  • auconaucon Posts: 2Questions: 0Answers: 0
    Allan Did you include that already?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Yes - if it isn't working for you can you firstly make sure you are using the latest nightly for Scroller ( http://datatables.net/download ) and secondly give me a link to a test case showing the problem.

    Allan
This discussion has been closed.