I am trying to implement cell List , and insert my data coming from server in my cell List , everything was working fine in celltable but now i have to switch to cellList which is not working
from GWT Show case i made this class
public class EmployerJobCell extends AbstractCell<EmployerJobs> {
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
EmployerJobs value, SafeHtmlBuilder sb) {
if (value == null) {
return;
}
sb.appendHtmlConstant("<table>");
// Add the contact image.
sb.appendHtmlConstant("<tr><td rowspan='3'>");
sb.appendHtmlConstant("</td>");
// Add the name and address.
sb.appendHtmlConstant("<td style='font-size:95%;'>");
sb.appendEscaped(value.getJobTitle());
sb.appendHtmlConstant("</td></tr><tr><td>");
sb.appendEscaped(value.getJobLevel());
sb.appendHtmlConstant("</td></tr></table>");
}
}
in my view class i did this
EmployerJobCell jobCell = new EmployerJobCell();
celllist = new CellList<EmployerJobs>(jobCell);
celllist.setPageSize(5);
verticalpanel.add(celllist);
but i am not getting any thing on my view .
do i have to use setRowData as well ?
If yes , how will I get my data
ArrayList<EmployerJobs > values = new ArrayList<EmployerJobs>();
celllist.setRowData(values);
like what will i put in my list
values. ??
CellListworks fundamentally the same asCellTable– both take a list of data, and draw them with aCell. The main difference is thatCellListonly draws one cell with each kind of content, whereas theCellTablecan draw several, each reading data differently from the model object.Both implement
HasData, allowing you to provide data and monitor selection, among other things. So in both cases, you should be callingwidget.setRowData(index, data)on each to get it to draw the content. So in short, to totally replace the content of a giveCellListwith aListcalledvalues, do something like this:Or, more simply, using
AbstractHasData.setRowData(List),This should get you to the point where you are displaying data.
Using paging makes this a little more complex – generally you use a paging widget like
SimplePager, and you provide the data not to theHasData, but to a data provider, which in turn hands it to the widget, based on the paging information. See http://code.google.com/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#paging and http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/javadoc/com/google/gwt/examples/view/AsyncDataProviderExample.java?r=8944 for some examples of how to do this by handing data off to aDataProviderfor it to manage, and letting anAbstractPagerallow the user to decide what they want to look at.