1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    17
    Vote Rating
    0
    longracer is on a distinguished road

      0  

    Default Is there any way to keep scroll position of Grid on load

    Is there any way to keep scroll position of Grid on load


    I've read the previous thread "Grid Loses Selection and Scroll Position On Data Store Load" and tried the way to restore scroll position after ds.load. It works, but "However there is still a visible twitch in the grid as it scrolls to the top and then back to the restored position.", I also tried :
    Code:
    grid = new Ext.grid.Grid('guests', {
                ds: ds,
                cm: colModel,
                view: new Ext.grid.GridView({
                    focusRow: Ext.emptyFn,
                    ensureVisible: Ext.emptyFn
                })
            });
    I think the option to turn off redraw grid while only update data in it is very important requirement. The typical usage such as real time stock quotes display has to have this option, or it can't work well, obviously. So can Ext team put some effort on it?

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    24
    Vote Rating
    0
    wck555 is on a distinguished road

      0  

    Default


    It's a bit of a hack, but if you create your grid as shown below, the grid scroll position will stay where it is when the data store is reloaded. The selection remains the same as well. The onLoad() function of the grid calls scrollToTop(). By eliminating scrollToTop(), the grid no longer moves when it is reloaded. The only drawback is that you can no longer call scrollToTop() on the grid.
    Code:
    new Ext.grid.Grid('parent', {
    ...
       view: new Ext.grid.GridView({ scrollToTop: Ext.emptyFn })
    });

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    17
    Vote Rating
    0
    longracer is on a distinguished road

      0  

    Default scrollToTop: Ext.emptyFn works!

    scrollToTop: Ext.emptyFn works!


    Thank you, wck555, It just works as you said. Though I have to forget scrollToTop, but I got a grid without blinking

  4. #4
    Sencha - Community Support Team JeffHowden's Avatar
    Join Date
    Mar 2007
    Location
    Forest Grove, OR
    Posts
    1,038
    Vote Rating
    1
    JeffHowden is on a distinguished road

      0  

    Default


    An alternative would be user Ext.override() to add a new method to the gridView that implements a copy of the scrollToTop() method. Then, override the built-in scrollToTop() method pointing it at the emptyFn() function, as mentioned above.

    Code:
    Ext.override(Ext.grid.GridView, {
        scrollTop : function() {
            this.scroller.dom.scrollTop = 0;
            this.scroller.dom.scrollLeft = 0;
        },
        scrollToTop : Ext.emptyFn
    });
    Now, if you need to actually scroll to the top, you call your own scrollTop() method.

    Yet another alternative is to use the override mentioned in the post above, and then simply access the gridView's scroller and call it's built-in scrollTo() method. Assuming "grid" is a variable holding a reference to your grid, you can do:

    Code:
    grid.getView().scroller.scrollTo('top', 0);
    Additionally, this approach means you can animate the scroll, if you choose:

    Code:
    grid.getView().scroller.scrollTo('top', 0, true);
    or get fancy with it:

    Code:
    grid.getView().scroller.scrollTo('top', 0, { easing: 'bounceOut' });
    Jeff Howden
    Ext JS - Support Team Volunteer
    jeff@extjs.com

    Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.

    Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    122
    Vote Rating
    0
    cocorossello is on a distinguished road

      0  

    Default


    Thx a lot guys, just what i was looking for

  6. #6
    Ext User
    Join Date
    Jun 2009
    Posts
    3
    Vote Rating
    0
    Chris_S is on a distinguished road

      0  

    Default


    I realize this thread is old, but I found my answer here and thought I'd add my solution for the next person that hits it...

    I came up with a less destructive version that I am using with 3.0:

    Code:
    Ext.override(Ext.grid.GridView, {
        holdPosition: false,
        onLoad : function(){
            if (!this.holdPosition) this.scrollToTop();
            this.holdPosition = false
        }
    });
    This way you don't have to remove the scrollToTop function and you can choose to override the scrollToTop behavior only at specific loads with something like:

    Code:
    grid.getView().holdPosition = true
    grid.getStore().reload()
    I needed this feature because I still want it to scroll to the top properly when I load with new parameters.

  7. #7
    Ext User
    Join Date
    Jul 2009
    Posts
    2
    Vote Rating
    1
    W3Design is on a distinguished road

      1  

    Default


    Quote Originally Posted by Chris_S View Post
    I realize this thread is old, but I found my answer here and thought I'd add my solution for the next person that hits it...

    I came up with a less destructive version that I am using with 3.0:

    Code:
    Ext.override(Ext.grid.GridView, {
        holdPosition: false,
        onLoad : function(){
            if (!this.holdPosition) this.scrollToTop();
            this.holdPosition = false
        }
    });
    This way you don't have to remove the scrollToTop function and you can choose to override the scrollToTop behavior only at specific loads with something like:

    Code:
    grid.getView().holdPosition = true
    grid.getStore().reload()
    I needed this feature because I still want it to scroll to the top properly when I load with new parameters.
    Thank you, your post was very helpful

  8. #8
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
    fdupont is on a distinguished road

      0  

    Default


    That's brilliant, thx.

  9. #9
    Sencha Premium Member milestonebass's Avatar
    Join Date
    Dec 2009
    Posts
    21
    Vote Rating
    0
    milestonebass is on a distinguished road

      0  

    Talking thanks..

    thanks..


    Thanks Chris_S. Neat override solution.

  10. #10
    Sencha User
    Join Date
    Aug 2011
    Posts
    1
    Vote Rating
    0
    Henry12 is on a distinguished road

      0  

    Default Stop Scrolling From Top

    Stop Scrolling From Top


    Can anybody send me the complete code of this problem.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."