Datagrid with ScrollPanel

591 views
Skip to first unread message

Nicolas Antoniazzi

unread,
Aug 16, 2011, 9:13:36 AM8/16/11
to google-we...@googlegroups.com
I would like to implement a Custom Pager for datagrid wich has quite the same behaviour as PageSizePager ("show more" button), but triggered by the scrollbar ("show more" called every time that the scrollbar reach the bottom of the table).
I would like to add a new ScrollHandler on DataGrid, but the ScrollPanel widget is not accessible.

Is there a way to get an accessor to this widget? Or does someone know another way to implement such widget ?

Thanks,

Nicolas.

Jeff Larsen

unread,
Aug 16, 2011, 9:37:18 AM8/16/11
to google-we...@googlegroups.com
Poking in the code of DataGrid, it looks like you could get access to it this way. 

HeaderPanel panel = (HeaderPanel) dataGrid.getWidget();
CustomScrollPanel scrollPanel = (CustomScrollPanel) panel.getContentWidget();

Admittedly, this isn't very clean, but it looks like it should work. 

Nicolas Antoniazzi

unread,
Aug 16, 2011, 9:40:47 AM8/16/11
to google-we...@googlegroups.com
Thanks jeff !
I'm going to try this :)

2011/8/16 Jeff Larsen <lars...@gmail.com>

ciosbel

unread,
Aug 16, 2011, 12:08:36 PM8/16/11
to google-we...@googlegroups.com
CellTable, DataGrid and in general all widgets that implements HasKeyboardPagingPolicy, have a KeyboardPagingPolicy field that can be set to INCREASE_RANGE in order to append the next page instead switching to it. Showcase shows this functionality with CellList, using a ShowMorePagerPanel (that extends AbstractPager) that uses an inner ScrollPanel to update the current range once the scrollbar reaches the end. But for the DataGrid should be the same: define the pager, add it to the DataGrid and set the KeyboardPagingPolicy.

Live example: http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList
The widget panel: http://www.google.com/codesearch#A1edwVHBClQ/samples/showcase/src/com/google/gwt/sample/showcase/client/content/cell/ShowMorePagerPanel.java&q=ShowMorePagerPanel%20%20package:http://google-web-toolkit\.googlecode\.com&type=cs

This is a somewhat unknown feature.

Jeff Larsen

unread,
Aug 16, 2011, 2:10:47 PM8/16/11
to google-we...@googlegroups.com
Oh cool, I never had need for CellList so I never really played with that example. 

Thanks!

KeyboardPaging seems like the wrong name if it can be used this way. 

ciosbel

unread,
Aug 17, 2011, 6:14:06 AM8/17/11
to google-we...@googlegroups.com
Sorry, my bad. HasKeyboardPagingPolicy is an interface implemented by CellTable<T> in 2.3 (in 2.4 or in trunk, the inheritance chain in slightly different but still working in the same manner) that defines a

setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)

with its getter counterpart. So, given a celltable (or datagrid) you just need to set something like

table.setKeyboardPagingPolicy(HasKeyboardPagingPolicy.INCREASE_RANGE)

That's it.
Reply all
Reply to author
Forward
0 new messages