有谁知道如何使CellList水平定向?如果可能的话,请与UiBinder协商,但这不是必需的。GWT CellList Horizontal
5
A
回答
1
试着重写CellList.renderRowValues方法。您必须能够创建一个水平的演示文稿模板。
1
有很多在该方法的逻辑我不想复制,但我只是跨度的更换所有的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));
}
}
0
与CSS一个变种 - 设置CSS类名你小区列表上
CellList<T> list = new CellList<T>(...);
list.addStyleName('myList');
然后应用CSS规则的细胞,使它们水平对齐:
.myList > div > div > div {
display: inline;
}
0
我可以通过扩展CellList和创建我自己的模板+覆盖renderRowValues方法来解决此问题。简单地将div转换为跨度对我来说并没有诀窍,也许是因为我有自定义单元格(每个单元格都以表格的形式呈现)。添加显示:内联CSS也不适用于我。
我的模板代码与原始代码几乎相同,只是我添加了“float:left;”风格:
interface Template extends SafeHtmlTemplates {
@Template("<div onclick=\"\" __idx=\"{0}\" style=\"float:left;\">{1}</div>")
SafeHtml span(int idx, SafeHtml cellContents); ...
这里是我的renderRowValue方法的一个片段:
2
继托马斯Broyer的建议on the google-web-toolkit group和How to style GWT CellList?,我们可以注入新的CSS资源到CellList构造。
用于获取horizonltal格式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);
请注意,新样式出现在DEFAULT风格后的级联中le为CellList,所以你只需要把你需要的修改放到你的MyCellList.css中。
相关问题
- 1. Horizontal Div Scroll
- 2. DevExpress Horizontal GridControl
- 3. jQuery Horizontal liteAccordion
- 4. ASP.NET Repeater Horizontal
- 5. UICollectionView Horizontal Scroll
- 6. Bootstrap Form-Horizontal Appearance
- 7. Center Bootstrap Modal horizontal
- 8. Infinite Horizontal Scrolling Div
- 9. Django Admin + Filter Horizontal?
- 10. GWT 2.6.1 CellList MediaQuery
- 11. GWT CellList setKeyboardSelected
- 12. ListView FullScreen-Item Scroll Horizontal
- 13. horizontal Bootstrap缩略图
- 14. richfaces中的Horizontal ScrollableDatatable
- 15. horizontal ScrollView Windows Phone 7
- 16. Liquid CSS only horizontal navigation bar
- 17. 帮助实现“Horizontal UITableViewController”?
- 18. android recyclerview center horizontal items
- 19. youtube like horizontal scroll div
- 20. HTML Divs,Columns,Horizontal Scroll Bar
- 21. float a horizontal centered div
- 22. ng grid horizontal scroll issue
- 23. Bootstrap“form-horizontal”和标签
- 24. Move Car Horizontal - Python classes
- 25. gwt CellList内的CheckBoxCell
- 26. CellList GWT CSS样式
- 27. 试图实现GWT cellList
- 28. GWT:设置为emptyListMessage CellList
- 29. 如何样式GWT CellList?
- 30. GWT CellList编辑细胞
你有没有得到一个很好的答案呢? – slugmandrew 2013-05-31 08:54:09