GWT 单元列表水平
有谁知道如何使 CellList 水平定向?如果可能的话,请使用UiBinder,但这不是必需的。
Does anybody know how to make a CellList oriented horizontally? If possible, please with UiBinder, but this is not necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
遵循 Thomas Broyer google-web-toolkit 群组 和 如何设置 GWT CellList 样式?,我们可以注入一个新的 CSS 资源进入 CellList 构造函数。
用于获取水平格式的 CSS
MyCellList.css
:定义一个新资源,如下所示:
注入新样式,并将其传递给 CellList 的构造函数:
请注意,新样式出现在级联中的 DEFAULT 样式之后CellList,因此您只需将所需的修改放入 MyCellList.css 中即可。
Following Thomas Broyer's suggestion on the google-web-toolkit group, and How to style GWT CellList?, we can inject a new CSS resource into the CellList constructor.
The CSS for getting the horizonltal formatting
MyCellList.css
:Define a new Resource like this:
Inject the new style, and pass it CellList's constructor:
Note that the new style appears in the cascade after the DEFAULT style for CellList, so you need only put the modifications you require into your MyCellList.css.
尝试重写 CellList.renderRowValues 方法。您必须能够创建水平演示模板。
Try to override the CellList.renderRowValues method. You have to be able to create a horizontal presentation template.
我不想重现该方法中有很多逻辑,但我用 span 替换所有 div 的黑客解决方案有效:
There is a lot of logic in that method I didn't want to reproduce, but my hacky solution of just replacing all div's with span's worked:
CSS 的变体 - 在单元格列表上设置 CSS 类名称
,然后将 CSS 规则应用于单元格以使它们水平对齐:
A variant with CSS - set CSS class name on you cell list
then apply CSS rule to the cells to make them align horizontally:
我可以通过扩展 CellList 并创建我自己的模板 + 覆盖 renderRowValues 方法来解决这个问题。简单地将 div 更改为 span 对我来说并没有什么效果,也许是因为我有自定义单元格(每个单元格都呈现为表格)。在 CSS 上添加 display:inline 对我来说也不起作用。
我的模板代码与原始代码几乎相同,除了我添加了“float:left;”样式:
这是我的 renderRowValue 方法的片段:
I'm able to solve this by extending CellList and creating my own template + overriding the renderRowValues method. Simply changing divs into spans didn't do the trick for me maybe it was because I have custom cells (each cell is rendered as table). Adding display:inline on the CSS didn't work for me also.
My template code is pretty much the same as the original except I added the "float:left;" style:
Here's a snippet of my renderRowValue method: