Results 1 to 8 of 8

Thread: Reset list scroll position to top

  1. #1

    Default 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 Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Code:
    list.scroller.scrollTo({
        x: 0,
        y: 0
    });

  3. #3

    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

    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.

  5. #5

    Exclamation 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

    Default 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

    Default

    Works great for me....Thanks!

  8. #8

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •