Grid.LoadNext() Returns to Top of Grid

I figured out how to dynamically load my touch grid thanks to the post here:

viewtopic.php?f=22&t=26851

However, whenever loadnext() is called, the grid is returned to the top. Is this working as intended or is this a bug? If it’s intended, is there a method to adjust the view to a certain location in the grid? Thanks,

Jake

Jake,

are you using the latest Touch version (v.1.2 build 120913) ? The problem is solved in this version.

Yes this problem is in the current version and I would also like a resolution for this.

I am using a bit of a kludge at the moment to return the view to the position when the data-load was triggered. This is only just passable as the grid scrolls to the top before scrolling to the final position.

// triggered by onAfterLoad
$$(_a.NAME + '_grid').scrollTo( _a.scrollState.x, _a.scrollState.y );

Yes, I am using the latest version I believe. I downloaded the lib.zip package posted at the end of the thread which I referenced and the bug is still there.

I have attached a working demo (the latest libs are used there). Please take a look
dynLoading.zip (204 KB)

Unfortunately the example attached has a couple of issues

  1. The issue is not solved. When using the load() function the data is appended but the grid returns to the top
  2. The formatting issue addressed in the linked post has regressed.

Many thanks,

James

After scrolling to the last loaded item, the next portion of data is shown. For example, when you scroll to the “Book 19” item, the grid loads next items and shows data from “Book 20” to “Book 27”. How can we reproduce the different behaviour ?

Use the load() method to load more data into the grid

I use the exact same call as you did and the latest libraries, and whenever new data is loaded into the grid, the grid scrolls back up to the top. This means the user has to keep scrolling down to get back to where they were every time new data is loaded.

$$('Client_Grid').attachEvent('onAfterScroll', function(pos) {
    var count = (Math.abs(pos.f)+this.$view.offsetHeight)/43;
    if((count+0.1)>=this.dataCount())
        this.loadNext(20);
});

Even some way to scroll to a specific position would be a fantastic work around for now, because then I can scroll back to their position prior to dynamic loading after the dynamic loading occurs.

Does the issue occur in the demo that I provided (without any changes) ?

You wrote about load() method. Are you using it instead of loadNext(num) ?

The demo works exactly like what I’m looking for. In fact, my loadNext(20) call is the exact same as yours and I replaced my touchui.js and touchui.css files with yours, and it still shows the top of the list.

I have not done much PHP programming, but from what I can tell, your JSON creates and returns only 20 items at a time. So it’s displaying the very first item every time which your data source returns.

My data source returns the top 20, then top 40, then top 60, which is why it’s always returning to the top - the item at the top of my data is the same every time. Rather, it should be returning the first 20, then the next 20, then the next 20 as yours does.

So I believe this issue is working with the supplied files - I just need to correct my code. Thank you!

Yes, jkantonen. I also encountered the same situation. Finally, I deal with so you can

$$('Client_Grid').attachEvent('onAfterScroll', function(pos) {
    var count = (Math.abs(pos.f)+this.$view.offsetHeight)/43;
    if((count+0.1)>=this.dataCount())
        this.loadNext(20, "", function(){
             this.scrollTo(0, 43*count);
        });
});