Hi, I am also trying to add a composite cell to table. Where you able to solve the problem?
Thanks, Ahmed On Mar 22, 3:03 pm, Blackberet <[email protected]> wrote: > I think I have this much correct; > > List<HasCell<ProjectDetails, ?>> aHasCells = new > ArrayList<HasCell<ProjectDetails, ?>>(); > aHasCells.add( > new HasCell<ProjectDetails, String>() > { > private ClickableTextCell cell = new > ClickableTextCell(); > > @Override > public Cell<String> getCell() > { > return cell; > } > > @Override > public FieldUpdater<ProjectDetails, String> > getFieldUpdater() > { > FieldUpdater<ProjectDetails, String> > fieldUpdater = > new > FieldUpdater<ProjectDetails, String>() > { > public void update(final int > index, final > ProjectDetails object, final String value) > { > Window.alert("LEFT"); > } > }; > return fieldUpdater; > } > > @Override > public String getValue(ProjectDetails object) > { > return object.getId() + ""; > } > }); > > aHasCells.add( > new HasCell<ProjectDetails, String>() > { > private ClickableTextCell cell = new > ClickableTextCell(); > > @Override > public Cell<String> getCell() > { > return cell; > } > > @Override > public FieldUpdater<ProjectDetails, String> > getFieldUpdater() > { > FieldUpdater<ProjectDetails, String> > fieldUpdater = > new FieldUpdater<ProjectDetails, > String>() > { > public void update(final int index, final > ProjectDetails object, final String value) > { > Window.alert("RIGHT"); > } > }; > return fieldUpdater; > } > > @Override > public String getValue(ProjectDetails object) > { > return object.getProjectLink(); > } > }); > > and then create the composite like this; > > CompositeCell<ProjectDetails> compositeCell = > new CompositeCell<ProjectDetails>(aHasCells) > { > @Override > public void render(Context context, ProjectDetails > value, SafeHtmlBuilder sb) > { > sb.appendHtmlConstant("<table><tbody><tr>"); > super.render(context, value, sb); > sb.appendHtmlConstant("</tr></tbody></table>"); > } > > @Override > protected Element getContainerElement(Element parent) > { > // Return the first TR element in the table. > return > parent.getFirstChildElement().getFirstChildElement().getFirstChildElement() ; > } > > @Override > protected <X> void render(Context context, > ProjectDetails value, SafeHtmlBuilder sb, > HasCell<ProjectDetails, X> > hasCell) > { > Cell<X> cell = hasCell.getCell(); > sb.appendHtmlConstant("<td>"); > cell.render(context, hasCell.getValue(value), sb); > sb.appendHtmlConstant("</td>"); > } > }; > > I don't know how to get the values from each of the cells in the > composite into the render method? > > Then this part had me totally confused; How do I add a Column composed > of these cells? > This doesn't work; > > Column<ProjectDetails, String> compositeCellColumn = > new Column<ProjectDetails, String>(compositeCell) > { > @Override > public String getValue(ProjectDetails object) > { > return object.getId() + ""; > } > }; > table.addColumn(compositeCellColumn, "COMPOSITE"); -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
