So... the official Scroller plug-in.

So... the official Scroller plug-in.

jcreadyjcready Posts: 44Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
The official Scroller plug-in that is listed in the Docs http://datatables.net/docs/ and the Extras page http://datatables.net/extras/ is broken when using DataTables v1.9.1 and Scroller v1.0.2. Even the official examples are broken. The state-saving example http://datatables.net/release-datatables/extras/Scroller/state_saving.html doesn't work on either Firefox 12.0b, Chrome 20.0dev or WebKit r114513.

And clicking the link to the API docs http://datatables.net/docs/Scroller/ takes you to a 403 Forbidden error page that just states:
[quote]You don't have permission to access /docs/Scroller/1.0.2/ on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.3.10 Server at datatables.net Port 80[/quote]
Navigating to http://datatables.net/docs/Scroller/1.0.1/ seem to work fine though.

Using the Scroller plug-in also seems to break a lot of the built-in features of DataTables such as retaining the paging position when filtering or sorting. Preforming either of those actions while using the Scroller plug-in take you to the very top of the dataset.

Replies

  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    Hi,

    Sorry about the trouble with the docs - I'm looking into what has gone wrong there and will fix it shortly - thanks for the heads up!

    > the Extras page http://datatables.net/extras/ is broken when using DataTables v1.9.1 and Scroller v1.0.2

    In what way broken? I might be missing something completely obvious, but the pages seem to work as expected for me. Likewise the state saving. Do you get a JS error on the pages or something else?

    > retaining the paging position when filtering or sorting. Preforming either of those actions while using the Scroller plug-in take you to the very top of the dataset.

    This is actually intentional - the idea was that when you click to sort or filter a data set, you are going to be completely rearranging the data, so rather than being left somewhere in the middle of the data set, you get taken to a known point - the start. This behaves the same way as DataTables core - for example go to page 4 on the example on the home page and then click to sort a column - it will jump back to the start of the data set.

    Regards,
    Allan
  • jcreadyjcready Posts: 44Questions: 0Answers: 0
    Thanks for the quick reply!

    [quote]In what way broken? I might be missing something completely obvious, but the pages seem to work as expected for me. Likewise the state saving. Do you get a JS error on the pages or something else?[/quote]

    When I first load the state saving example everything works as expected (no cookie yet), but after I scroll down a bit and refresh the page, all I get is this in Firefox, Chrome and Safari: http://cl.ly/FyGg

    Mind you, my browsers are running beta, dev, and nightly versions so it could have something to do with that. However there are no javascript errors on any of the browsers and my version of Safari has no extensions or scripts being injected. I also tried disabling dotjs on Firefox and Chrome but it didn't help.

    [quote][quote]retaining the paging position when filtering or sorting. Preforming either of those actions while using the Scroller plug-in take you to the very top of the dataset.[/quote]

    This is actually intentional - the idea was that when you click to sort or filter a data set, you are going to be completely rearranging the data, so rather than being left somewhere in the middle of the data set, you get taken to a known point - the start.[/quote]

    Ahh, I guess I was mistaken. Sorry about that. I'm developing a music library type interface and obviously the list of songs (my DataTable) is going to have thousands of rows an anywhere from 4 to 10 columns (lots of data). One thing that I'm trying to accomplish is mimicking iTunes' filtering functionality. After you filter your library in iTunes, you can select or play a song, clear the filter/search box, and when iTunes redraws the table, that song will be scrolled into view in the very top row.

    One other thing I'm struggling with is getting the "next song" to play after the currently playing row has either finished or the user has clicked the next button in the player controls. I already have everything set up to play the correct music when a user double clicks the row, and I also have code in place to double click the next row if the song ends or the user clicks next. But if that row has been scrolled out of view, none of the code works. I'm sure there's a way to get the data, but I also need to add a class to that row to indicate that it is the current track.

    I found the fnGetAdjacentTr() plug-in and I hoped that it would fix it, but it also seems to have the same problem.
  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    > after I scroll down a bit and refresh the page, all I get is this in Firefox, Chrome and Safari: http://cl.ly/FyGg

    Brilliant - thanks for the explanation. I've just committed a fix for this issue (basically I'm afraid I had neglected to update the state saving in Scroller for 1.9 :-( ). The fix can be obtained from the 1.0.3.dev nightly on the download page: http://datatables.net/download

    Regarding the documentation - I've corrected the error in the generated documentation and its back online here: http://datatables.net/docs/Scroller/1.0.2/Scroller.html :-)

    > when iTunes redraws the table, that song will be scrolled into view in the very top row.

    Sounds interesting - what you could do is use fnDrawCallback and if the oSettings.bFiltered or oSettings.bSorted flags are set then use Scroller's fnScrollToRow method (you need a way to convert the row node to the index, or however it is you know what the row is - a small API method might be needed for that).

    > One other thing I'm struggling with is getting the "next song" to play after the currently playing row has either finished

    Are you using server-side processing, or client-side? fnGetAdjacentTr will only work with client-side processing (since with server-side processing the old row will no longer exist - you would need to track by an ID or something for server-side processing). For client-side processing I would expect fnGetAdjacentTr to work, as long as you have the TR node for the currently playing song stored?

    Sounds like a really interesting project! Please keep the questions coming - I'd be most interested in hearing how it pans out for you!

    Regards,
    Allan
  • jcreadyjcready Posts: 44Questions: 0Answers: 0
    edited April 2012
    [quote]I've just committed a fix for this issue (basically I'm afraid I had neglected to update the state saving in Scroller for 1.9 :-( ). The fix can be obtained from the 1.0.3.dev nightly on the download page: http://datatables.net/download [/quote]

    This works brilliantly! Thank you so much. And thank you for pointing me in the right direction regarding my other two questions. I'll be sure to update you on my progress!
  • JustinPierceJustinPierce Posts: 3Questions: 0Answers: 0
    edited April 2012
    Not to hijack this thread, but I'm seeing some related weirdness that I can replicate here: http://datatables.net/release-datatables/extras/Scroller/server-side_processing.html

    To reproduce, do the following:

    1. Scroll the list far enough that it pulls data from the server.
    2. Sort by any column.

    What will happen is that the table will jump to the top (expected) and then all of your records will vanish. Looking at my debug tools, what appears to be happening is that DataTables is requesting data twice: once for the top of the list and then again for the position you just left.

    Since the second result replaces the first, it appears that all of your records vanished. In actuality, it just loaded a page of data that is scrolled out of view.

    I'm guessing that this behavior is not intended, but since it's in your examples, I'm also guessing that there's no out-of-the-box way to prevent it.
  • JustinPierceJustinPierce Posts: 3Questions: 0Answers: 0
    I did some digging, and there appears to be a disconnect between the state of the Scroller and the state of the DataTable. What appears to be happening is this:

    1. Upon sorting, DataTables goes to record 0 and fetches data.
    2. The act of scrolling to the top fires the scroll event, which the Scroller handles in _fnScroll.
    3. _fnScroll makes its own call to _fnDraw, but it sets _iDisplayStart to its last scroll position. This causes the previous view of data to be fetched.
  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    > I'm guessing that this behavior is not intended

    Heh - no it is absolutely not intended! Its a bug :-(

    Thanks for your analysis of the problem! It will make fixing it much easier! I'll post back here when I've committed a fix.

    Allan
  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    I've just committed the fix - you saved me a good bit of time with the debugging - thanks! And thanks also for the donation :-)

    What I've done is to have Scroller draw callback no act when either a filtering or sorting event has occurred on the table. I suspect that there are other ways of doing it and possibly some of them might be better than what I have implemented just now, so I'm going to keep this open in my tracker and have a bit of a proper think about it because making the next Scroller release. However, until then the current fix is available in the nightly on the downloads page: http://datatables.net/download .

    Thanks very much for flagging this up!

    Regards,
    Allan
  • JustinPierceJustinPierce Posts: 3Questions: 0Answers: 0
    This is pretty similar to the temporary fix I was about to commit. Thanks for the quick fix!
This discussion has been closed.