1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    2
    Vote Rating
    0
    vemCastro is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    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).

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    2
    Vote Rating
    0
    vemCastro is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Location
    Romania
    Posts
    4
    Vote Rating
    0
    carbotox is on a distinguished road

      0  

    Default


    You can take the scroll state and restore it after sort is done.

    getting scrollState before sort:
    Code:
    getStore().addListener(Store.BeforeSort,
                    new Listener<StoreEvent<HMapModel>>() {
    
                        @Override
                        public void handleEvent(StoreEvent<HMapModel> be) {
                            if (isRendered()) {
                                scrollState = getView().getScrollState();
                            }
                        }
                    });
    Apply scrollState aftre sort is done:

    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

  1. Once do sorting in a grid, how to disable sorting then?
    By rosemondi in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Apr 2010, 9:04 AM
  2. Once do sorting for a grid, then how to disable sorting?
    By rosemondi in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 7 Apr 2010, 7:32 PM
  3. Restore scroll state on server side grid sorting
    By snehaltikekar in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 2 Nov 2009, 5:10 PM
  4. grid Autosave works fine for add and edit, but will it affect destroy also
    By gajendrabang in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 2 Oct 2009, 9:04 AM
  5. grid affect tab open/close speed?
    By kirk in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 18 Jan 2007, 12:04 AM

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar