1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Boston
    Posts
    7
    Vote Rating
    0
    chimney is on a distinguished road

      0  

    Default Grid store refresh scrollToTop problem

    Grid store refresh scrollToTop problem


    I have a problem using GXT grid. It automatically scrolls to upper left position upon adding new data to it.
    Here are the things I have tried but didn't solve the problem:
    1) overriding GridView's scrollToTop and make it do nothing, but this didn't solve the problem.
    2) remember last scrolled position and set it back.
    public void onSuccess(List<> result) {
    int top = grid.getView().getScroller().getScrollTop();
    int left = grid.getView().getScroller().getScrollLeft();
    grid.getStore().removeAll();
    grid.getStore().add(result);
    grid.getView().getScroller().scrollTo("top", top);
    grid.getView().getScroller().scrollTo("left", left);
    ...............
    }
    this somewhat solved the problem, but it causes a flash when grid scrolls back to position. My grid contains cells and headers with different colors, so this flash became very annoying with colors flying back and forth every data change. So this solution isn't good enough.
    Has anyone encounter this problem before? I am running out of ideas, please give me some hint on how to fix this. Thanks.

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    Boston
    Posts
    7
    Vote Rating
    0
    chimney is on a distinguished road

      0  

    Default


    I believe I found a solution. The code that cause the scroll problem is not just scrollToTop. GridView.refresh is also causing the problem.
    refresh() does a mainBody.setInnerHtml(renderRows(0, -1)); and this clears the grid which causing grid to scroll back to (0, 0) after new data is added.
    I avoid refresh() by using grid.getStore().update()

    public void onSuccess(List<M> result) {
    sumPnL = 0d;
    int top = grid.getView().getScroller().getScrollTop();
    int left = grid.getView().getScroller().getScrollLeft();
    System.out.println("store size: "+grid.getStore().getCount());
    if (grid.getStore().getCount() < 1) {
    grid.getStore().removeAll();
    grid.getStore().add(result);
    } else {
    for (M m : result) {
    grid.getStore().update(m);
    }
    }
    ...
    ...
    }

    I override GridView scrollToTop() and made it do nothing,
    I also override ListStore method findModel() and update() to get this to work. So far this solution worked, I will post if there are further problems. Hope this will help anyone with similar problem.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Boston
    Posts
    7
    Vote Rating
    0
    chimney is on a distinguished road

      0  

    Default


    The solution mentioned above caused another problem, when grid is large (>3700 cells), speed is slow. When I use update on every row, it caused user to lost focus of the app for a long period of time...

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