有誰知道如何使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