1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    82
    Vote Rating
    0
    jacstofberg is on a distinguished road

      0  

    Default Reset list scroll position to top

    Reset list scroll position to top


    Hi there,

    This may seem a silly question, but I just can't figure out how to reset a list's scroll position back to zero (top). I reload my list store dynamically and the new store often contains less elements than the previous one. The result is that if the first (longer) list happened to be scrolled a fair amount to the bottom, the new (shorter) list's elements cannot be seen upon loading the new store unless one scrolls all the way to the top by hand.

    Your help is much appreciated.

    Kind regards,
    Jac

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,989
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Code:
    list.scroller.scrollTo({
        x: 0,
        y: 0
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    82
    Vote Rating
    0
    jacstofberg is on a distinguished road

      0  

    Default


    Thank you for the prompt reply It works like a charm.

    Cheers,
    Jac

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Location
    Vicenza, Veneto, Italy
    Posts
    18
    Vote Rating
    0
    MPeg is on a distinguished road

      0  

    Question


    Hi, can you paste an example code starting from a List istantiation to show how and where to use the scrollTo() method? Thanks!

    PS: I wrote a little entry in my blog to document an issue to List scrolling fixed whit the help of this thread! http://goo.gl/f7oVY.
    Follow my blog at: MovableApp.com!
    http://twitter.com/#!/movableapp - My Sencha Touch Learning Experience

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    32
    Vote Rating
    0
    hrishikeshp19 is on a distinguished road

      0  

    Exclamation list.scroller does not work

    list.scroller does not work


    scroller is not a part of list, so list.scroller does not work. Please help

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    25
    Vote Rating
    0
    grnadav is on a distinguished road

      0  

    Default list.scroller exists

    list.scroller exists


    Quote Originally Posted by hrishikeshp19 View Post
    scroller is not a part of list, so list.scroller does not work. Please help
    it exists only after rendering
    do
    Code:
    if (list.rendered) {	list.scroller.scrollTo({x:0, y:0});
    }
    working on Secha Touch 1.1.1

  7. #7
    Sencha User
    Join Date
    Dec 2010
    Posts
    1
    Vote Rating
    0
    stereodinamico is on a distinguished road

      0  

    Default


    Works great for me....Thanks!

  8. #8
    Sencha User
    Join Date
    Mar 2010
    Posts
    3
    Vote Rating
    0
    openxtiger is on a distinguished road

      0  

    Default


    Code:
    Ext.override(Ext.DataView,{
        refresh: function() {
            if (!this.rendered) {
                return;
            }
    
    
            this.fireEvent('beforerefresh', this);
            var el = this.getTargetEl(),
                records = this.store.getRange();
            el.update('');
            if (records.length < 1) {
                if (!this.deferEmptyText || this.hasSkippedEmptyText) {
                    el.update(this.emptyText);
                }
                this.all.clear();
            } else {
                this.tpl.overwrite(el, this.collectData(records, 0));
                this.all.fill(Ext.query(this.itemSelector, el.dom));
                this.updateIndexes(0);
            }
            this.hasSkippedEmptyText = true;
    
    
            if (this.scroller) {
                this.scroller.scrollTo({x:0, y:0});
            }
    
    
            this.fireEvent('refresh', this);
        }
    });

Similar Threads

  1. [OPEN] [FIXED-212] List not reducing scroll position after reload
    By meyerovb in forum Sencha Touch 1.x: Bugs
    Replies: 4
    Last Post: 31 Jan 2012, 10:34 PM
  2. scroll list to the top on refresh
    By wakatanka in forum Sencha Touch 1.x: Discussion
    Replies: 7
    Last Post: 9 Aug 2010, 4:49 AM
  3. How to move scroll bar position to the top after saving
    By pearl_123 in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 11 Dec 2009, 8:09 AM
  4. Scroll scroll scroooolllll at a fixed position !!!
    By j-mi-jim in forum Community Discussion
    Replies: 0
    Last Post: 12 Feb 2009, 6:49 AM
  5. Open tab will reset scroll position when unfocused.
    By mscifo in forum Ext 1.x: Bugs
    Replies: 4
    Last Post: 7 Dec 2006, 11:03 AM

Thread Participants: 6

Tags for this Thread