4

I was implementing a custom CellTable that has a infinite scroll feature using the CellList showcase example ( http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ). However, I found a feature in CellList/Table that is undesirable in this case: changing visible range after clicking an item would cause the List/Table to be automatically scrolled to the selected item.

you can try the showcase example in above to see the exact same behavior. When no item is selected, the infinite scroll works just fine, but when you click an item and then scroll it, it will always jump back to the selected item when the range is changed.

I also found that it only happens when the focus is still on the item, that is, if you select an item and then click somewhere else to lose the focus, it wouldn't happen.

I've been digging around the GWT code and trying to find out how to disable this feature with no success. Did anyone handled this situation before?

pg30123
  • 65
  • 4
  • this is weird: my client is complaining about the _absence_ of the behaviour you just described, and I can’t get my celltable to scroll to the selected entry when refreshed :( – törzsmókus Apr 28 '13 at 13:12
  • also, the showcase example does not jump back for me. they might have fixed it. – törzsmókus Apr 28 '13 at 13:13
  • @törzsmókus Just tried the show case with Chrome 27 and the issue still did happen. It also does not occur when the focus is for example on one of the edit text boxes. – Tom Fink Jul 01 '13 at 12:11

2 Answers2

3

As a simple workaround, you can call focus() on some element, to remove the focus from the item (without removing the selection).

In the showcase example, in ShowMorePagerPanel, add e.g.

scrollable.getElement().focus();

at the beginning of the onScroll(ScrollEvent event) method.

Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
  • 2
    That's indeed a fast way to get it working, thx! However, I still think it would be better if we can simply disable that behavior. – pg30123 Aug 06 '12 at 11:18
0

I ran into the same problem and couldn't get Chris's answer to solve it, but the following solution worked for me:

in your onScroll(ScrollEvent event) method, add a line similar to the following, assuming yourTable is an instance of something extending AbstractHasData

yourTable.setFocus(false);
cyk
  • 1
  • 1