Results 1 to 6 of 6

Thread: How on first load to show a dataView contents completely scrolled down for a chat

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Vote Rating
    0
      0  

    Default How on first load to show a dataView contents completely scrolled down for a chat

    I now do it with this code:

    Code:
    var _this = this;
    store.addListener('load', function() {
      setTimeout(function() {
        _this.scrollToBottom(true);
      }, 500);
    });
    Note that I need a setTimeout(), because when I receive the callback the list is not rendered yet.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You need to get the scroller class so you can use the scrollToEnd. To do this:

    Code:
    var scroller = dataview.getScrollable().getScroller();
    Now you can do

    Code:
    scroller.scrollToEnd(true);
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Vote Rating
    0
      0  

    Default

    I do this in
    _this.scrollToBottom(true);.
    The problem is that I need a setTimeout for this to have effect. Is there some kind of event, view method override I can use for this?

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You can listen for the refresh event on the dataview. That should technically fire after the items are rendered, may need to use the after order or single option:

    Code:
    dataview.on('refresh', function() {}, dataview, { single : true }, 'after');
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Actually this works when the data is already found in the store. However when the data has to be retrieved from the proxy (first time load), then this callback does not fire at the right moment. Could this be a bug, or is this expected behaviour?

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    The refresh event should fire after after the store has data as the dataview reflects the data in the store.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •