Dynamically set "page size" of CellList

73 views
Skip to first unread message

Paul Schwarz

unread,
Jun 24, 2010, 11:08:00 AM6/24/10
to Google Web Toolkit
I have a CellList implementation (not a CellTable) and the "cells" to
be displayed correspond to a day on a calendar. I am "paging" through
my data by month. So as you can imagine, January needs to be 31 cells
long, February needs to be 28 or 29 cells long, etc.

A cell list has a "private static final int DEFAULT_PAGE_SIZE = 25;",
so this must be overridden somehow. I have made three attempts,
neither are ideal:

Attempt 1:
listViewAdapter.setList(list);
cellList.setPageSize(list.size());
... superficially works, but in actual fact it is rendering the
CellList twice! The first render is triggered by setting the list
data, and then the second render is triggered because the "range" has
changed. If I reverse these two lines of code it has the same effect.

Attempt 2:
cellList.setData(0, list.size(), list);
... fixes the double-rendering problem, but doesn't work because my
page size is back to the default 25 cells.

Attempt 3:
listViewAdapter.setList(list);
cellList.setDataSize(list.size(), true);
... same result as Attempt 2.

The reason why Attempts 2 and 3 didn't work (I think) is because of
this code found in CellList.java:
public void setData(int start, int length, List<T> values) {
impl.setData(values, start);
}
... notice how the length arg is never used or passed to the
implementation.

Before I go ahead and roll my own implementation is there a way for me
to get the desired effect with the standard CellList?

Paul Schwarz

unread,
Jun 24, 2010, 12:37:09 PM6/24/10
to Google Web Toolkit
Ok it's not great, but here is my work around:
A month has at most 31 days, so before placing data into the CellList
set its page size to 31. Now at you page through your months just
update the CellList by giving it the new data. 31 is big enough so
that page truncation wont occur, and if it's less that 31, like a
month with 30 days then so what, it just wont render an entry for 31.
Problem solved... sort of.

Paul Schwarz

unread,
Jun 26, 2010, 6:59:25 AM6/26/10
to Google Web Toolkit
Does anyone have an idea of how to do this short of creating my own
CellList implementation? I am happy with workaround as described in
post #2 above, but this doesn't help in the general case.
Reply all
Reply to author
Forward
0 new messages