-
17 Feb 2011 2:54 PM #1
Sorting grid does not affect the scroll
Sorting grid does not affect the scroll
hi guys,
He needed a helping hand in a specific case. I am using the grid component and having a problem. In my grid i have many items, if you select one of the elements present on the bottom of the list, and then sort the grid by a column, the scroll to do when the sort is always pulled to the beginning, and therefore do not see my item selected. How can I keep my selected item always visible, or that the ordinance does not affect the scroll?
Sorry my bad english.
Thanks
-
17 Feb 2011 4:38 PM #2
Add a listener to the sort event (probably on the ListStore), and then tell the grid to scroll to the currently selected items (using the SelectionModel).
-
18 Feb 2011 1:18 AM #3
Not exactly what I needed.
the item always remains selected, however as the scroll is placed at the beginning visually lose the selected item. I want to always view the selected element.
-
18 Feb 2011 7:45 AM #4
And that is what I said - once you catch the event indicating that a sort has occurred, instruct the Grid to scroll to the given element. I know it remains selected - the state of the grid shouldn't change over a local sort, but the grid's viewport doesn't know to keep that element in view, so you must fire a grid.getGridView().ensureVisible(row, 0, false) call to make sure the row is shown.
Note that this call can be used to ensure a given column is visible as well, and can set horizontal scroll as well, but from your usecase, I don't think you want either of those.
-
10 Aug 2012 12:56 AM #5
You can take the scroll state and restore it after sort is done.
getting scrollState before sort:
Apply scrollState aftre sort is done:Code:getStore().addListener(Store.BeforeSort, new Listener<StoreEvent<HMapModel>>() { @Override public void handleEvent(StoreEvent<HMapModel> be) { if (isRendered()) { scrollState = getView().getScrollState(); } } });
Code:addListener(Events.SortChange, new Listener<GridEvent<ModelData>>() { @Override public void handleEvent(GridEvent<ModelData> be) { restoreScrollerState(); } });Code:private void restoreScrollerState() { if (scrollState != null) { El scroller = getView().getScroller(); if (scrollState.y < scroller.getWidth()) { scroller.setScrollLeft(scrollState.x); } if (scrollState.x < scroller.getHeight()) { scroller.setScrollTop(scrollState.y); } } }
Similar Threads
-
Once do sorting in a grid, how to disable sorting then?
By rosemondi in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 8 Apr 2010, 9:04 AM -
Once do sorting for a grid, then how to disable sorting?
By rosemondi in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 7 Apr 2010, 7:32 PM -
Restore scroll state on server side grid sorting
By snehaltikekar in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 2 Nov 2009, 5:10 PM -
grid Autosave works fine for add and edit, but will it affect destroy also
By gajendrabang in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 2 Oct 2009, 9:04 AM -
grid affect tab open/close speed?
By kirk in forum Ext 1.x: Help & DiscussionReplies: 0Last Post: 18 Jan 2007, 12:04 AM


Reply With Quote