有人知道如何制作水平方向的CellList吗?如果可能,请使用UiBinder,但这不是必需的。
发布于 2014-08-29 20:13:30
遵循Thomas Broyer的建议on the google-web-toolkit group和How to style GWT CellList?,我们可以向CellList构造函数注入一个新的CSS资源。
用于获取水平格式MyCellList.css的CSS
/* This file is based on the CSS for a GWT CellList:
* https://gwt.googlesource.com/gwt/+/master/./user/src/com/google/gwt/user/cellview/client/CellList.css
* The primary purpose is to arrange for the <div> elements that contain each cell to be laid out inline (horizontally).
*/
/* Using inline-block, following Thomas Broyer's recommendations (with link to justification) here:
* https://groups.google.com/forum/#!topic/google-web-toolkit/rPfCO5H91Rk
*/
.cellListEvenItem {
display: inline-block;
padding: 5px;
}
.cellListOddItem {
display: inline-block;
padding: 5px;
}像这样定义一个新资源:
public interface MyCellListResource extends CellList.Resources {
public static MyCellListResource INSTANCE = GWT.create(MyCellListResource.class);
interface MyCellListStyle extends CellList.Style {}
@Override
@Source({CellList.Style.DEFAULT_CSS, "MyCellList.css"})
MyCellListStyle cellListStyle();
}注入新样式,并将其传递给CellList的构造函数:
MyCellListResource.INSTANCE.cellListStyle().ensureInjected();
CellList<Fare> cellList = new CellList<Fare>(cell, MyCellListResource.INSTANCE);请注意,新样式出现在CellList的默认样式之后的级联中,因此您只需将所需的修改放入MyCellList.css中。
发布于 2010-12-21 13:41:14
尝试重写CellList.renderRowValues方法。您必须能够创建水平演示模板。
发布于 2012-09-22 05:53:44
这个方法中有很多我不想重复的逻辑,但我的老生常谈的解决方案就是用span的div替换掉所有的div:
public class HorizontalCellList<T> extends CellList<T> {
public HorizontalCellList(Cell<T> cell) {
super(cell);
}
@Override
protected void renderRowValues(
SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel) {
SafeHtmlBuilder filteredSB = new SafeHtmlBuilder();
super.renderRowValues(filteredSB, values, start, selectionModel);
SafeHtml safeHtml = filteredSB.toSafeHtml();
String filtered = safeHtml.asString().replaceAll("<div", "<span").replaceAll("div>","span>");
sb.append(SafeHtmlUtils.fromTrustedString(filtered));
}
}https://stackoverflow.com/questions/4374863
复制相似问题