Search code examples
gwtgxt

GXT 3 - Sorting causes grid to horizontally scroll


If I try to sort a column that's out of view (I need to scroll on the right to see it) then the column sorts but the table scrolls back to the left, (and the column i sorted is out of view again)

One can try this in the Basic Gid of the GXT showcase: Just make the width of the columns larger so that the horizontal scroller shows up and then try to scroll at the end of the table and sort.

How to fix this?

Thanks


Solution

  • This is how I solved it: Override onDataChanged of GridView and set preventScrollToTopOnRefresh to true before sorting and then set it back to whatever it was. I wonder why this is not the default behaviour.

    final GroupSummaryView<Row> view = new GroupSummaryView<Row>()
    {
          protected void onDataChanged(StoreDataChangeEvent<Row> se) 
          {
              boolean b = preventScrollToTopOnRefresh;
    
              preventScrollToTopOnRefresh = true;
    
              super.onDataChanged(se);
    
              preventScrollToTopOnRefresh = b;            
          }
    };
    
    _table.setView(view);