-
22 Nov 2010 7:46 PM #1
need a help about the gridpanel`s store refresh
need a help about the gridpanel`s store refresh
i did a gridpanel,want to keep the scrollbar`s state when the gridpanel refresh.
i can get the scrollbar`s top,left when the store beforeload use 'getScroll() ',and save it to store like 'store.scrollsObj'
then i did code in the event 'load',
when i break debug it ,i find it can do ,but when the gridpane fresh over the scrollbar also go to left:0,top:0Code:var showPanle = tab.getGridEl().down('.x-grid3').down('.x-grid3-viewport').down('.x-grid3-scroller') showPanle.scrollTo('top',store.scrollsObj.top+10); showPanle.scrollTo('left',store.scrollsObj.left+10);
why?
shoud i take another event?
-
22 Nov 2010 10:30 PM #2
-
23 Nov 2010 2:46 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
So you want:
Code:var state; grid.getStore().on({ beforeload: function(){ if (grid.rendered) { state = grid.getView().getScrollState(); } }, load: function(){ if (state) { grid.getView().restoreScroll(state); } } });
-
23 Nov 2010 6:04 PM #4
-
12 Feb 2013 9:42 AM #5
Hi,
I am trying to achieve the same goal (i.e. keeping the scroll position when the grid is refreshed). The store is automatically refreshed every 5 seconds (by an ajax call) with the function:
This function does not fire the beforeload event, so I tried another way by monitoring the bodyscroll event of the grid panel with:Code:RealtimeStore.loadData(realdata);
and reloading the scroll state on the store reloading (as explained in the previous posts):Code:var realtimeGridState; RealtimeGridPanel.on({ bodyscroll: function(){ if (RealtimeGridPanel.rendered) { realtimeGridState = RealtimeGridPanel.getView().getScrollState(); console.log('Store ',realtimeGridState); } } });
The realtimeGridState is well registered (log are correct), but no matter what, the scroll position is always reset to 0,0 when the grid is refreshed.Code:RealtimeGridPanel.getStore().on({ load: function(){ if (realtimeGridState) { RealtimeGridPanel.getView().restoreScroll(realtimeGridState); console.log('Load ',realtimeGridState); } } });
Any idea of what is happening?
Thank you!
NB: using ExtJS 3.4.1
Similar Threads
-
store.remove(rec) doesn't refresh, but store.removeAll() does?
By ekhanh101 in forum Ext 3.x: Help & DiscussionReplies: 9Last Post: 23 Nov 2010, 5:34 AM -
How to refresh GridPanel?
By ctp in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 25 Oct 2010, 9:23 PM -
How to refresh a gridPanel?
By mainmich in forum Ext 3.x: Help & DiscussionReplies: 7Last Post: 17 Jun 2010, 3:10 AM -
How to refresh GridPanel
By silcreval in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 29 Dec 2008, 5:11 AM -
gridpanel store.loadData doesnt refresh data
By onedaysale in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 13 Aug 2008, 11:18 AM


Reply With Quote