Table and programatically scrolling back to first item not working

Hi,

i have a table with lots of items. When clicking a button it selects the next item in the table.

This is pretty easy as i just call

table.select(item id);
table.setCurrentPageFirstItemId(item id);

The table has a pagesize
table.setPageLength(table.size());

Now when i want to move back to the first item that does not work anymore. i again call
table.select(item id);
table.setCurrentPageFirstItemId(item id);

But it only selects the first item, but does not scroll to it.

Is there anything wrong with that?

I made a small test program to check if the problem still exists in a different environment than our program. Heres the test code:

[code]
@Theme(“mytheme”)
@SuppressWarnings(“serial”)
public class MyVaadinUI extends UI
{

private int counter = 0;
private int items = 40;

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "com.barco.bcm.AppWidgetSet")
public static class Servlet extends VaadinServlet {
}

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);
    
    IndexedContainer ic = new IndexedContainer();
    ic.addContainerProperty("Counter", Integer.class, 0);
    
    final Table t = new Table();
    t.setSortEnabled(false);
    t.setContainerDataSource(ic);
    t.setImmediate(true);
    t.setWidth("200px");
    t.setHeight("600px");
    
    for (int i = 0; i < items; i++){
        ic.addItem(i);
        ic.getContainerProperty(i, "Counter").setValue(i);
    }
    
    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            getUI().access(new Runnable() {
                
                @Override
                public void run() {
                    t.select(counter);
                    t.setCurrentPageFirstItemIndex(counter);
                    t.refreshRowCache();
                    
                    counter++;
                    if (counter == items){
                        counter = 0;
                    }
                }
            });

        }
    });
    layout.addComponent(t);
    layout.addComponent(button);
}

}
[/code]It works until i get to item 40. Then when i click again it selects Item 0, but does not scroll to it. When i click again it selects Item 1 and scrolls to Item 1.

I just tested it by copying your exact code into a Vaadin 7.3.5 and it worked totally fine in Chrome.
Which Vaadin version/Browser did you use and could you try testing it with another one?

I used 7.2.5 and Chrome, IE, Firefox. All had the same issue. Will try with 7.3.5 and report back.

It seems to be a problem in 7.2.5 as i quickly changed the version in my project and immediately was able to reproduce the behaviour

The problem is, that i modified lots of styles and in 7.3.5 these do not have the same effect as in 7.2.5…Well guess i have to change that then…Thanks for your help.

You could try the latests 7.2 version (which is 7.2.7 i think) and see if it was already fixed there. Then you may not have to rewrite your styles.

7.2.7 seems to work. Just tried it. But it also works to use 7.3.5 for everything except themes that i left with version 7.2.5

Have to check which way is better, guess its better to stick to 7.2.7 as it fits together better.

Thanks again. You saved me some hours of work :wink: