Thursday, November 25, 2010

CellList: setVisibleRange

I'm having trouble understanding what the CellList
setVisibleRange(start,length) function is actually supposed to do.
Here is a simple example that seems to have unexpected results:

public class ExampleCellList implements EntryPoint {

public void onModuleLoad() {
DockLayoutPanel dock = new DockLayoutPanel(Unit.PX);

TextCell textCell = new TextCell();
final CellList<String> cellList = new CellList<String>(textCell);
cellList.setPageSize(10);

List<String> data = new ArrayList<String>();
for(int i = 0; i < 100; i++) {
data.add("row: " + i);
}
cellList.setRowData(0, data);

final Button up = new Button("UP");
up.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
int start = cellList.getVisibleRange().getStart() - 1;
int length = cellList.getVisibleRange().getLength();
cellList.setVisibleRange(start, length);
up.setText("" + cellList.getVisibleRange().getStart() + ":" +
cellList.getVisibleRange().getLength() + ":" + cellList.getPageStart()
+ ":" + cellList.getPageSize());
}
});

final Button down = new Button("DOWN");
down.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
int start = cellList.getVisibleRange().getStart() + 1;
int length = cellList.getVisibleRange().getLength();
cellList.setVisibleRange(start, length);
down.setText("" + cellList.getVisibleRange().getStart() + ":" +
cellList.getVisibleRange().getLength() + ":" + cellList.getPageStart()
+ ":" + cellList.getPageSize());
}
});

dock.addNorth(up, 30);
dock.add(cellList);
dock.addSouth(down, 30);

RootLayoutPanel.get().add(dock);

}

}


I expect the list to store the data I add to it and display the range
I specify, but instead, it seems to remove elements whenever I use
setVisibleRange.

Any ideas on what I'm doing wrong?

Andrew Arnott

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment