是否可以在GWT中设置CellTable
的列宽?GWT CellTable - 设置列宽
15
A
回答
24
编辑:由于GWT 2.2 table.setWidth和table.setColumnWidth支持
table.setWidth("100%", true);
table.setColumnWidth(nameColumn, 35.0, Unit.PCT);
table.setColumnWidth(addressColumn, 65.0, Unit.PCT);
我能够与编程设定宽度的方法延长CellTable。这是一个黑客,因为所有真正的方法应该这样做是CellTable专用的,看起来GWT应该直接提供这种方法,但它似乎工作。
public void setColumnWidths(List<Integer> widths)
{
TableElement tel = TableElement.as(getElement());
NodeList<Element> colgroups = tel.getElementsByTagName("colgroup");
if (colgroups.getLength() == 1)
{
TableColElement cge = TableColElement.as(colgroups.getItem(0));
NodeList<Element> cols = cge.getElementsByTagName("col");
for (int j = 0; j < widths.size(); j++)
{
TableColElement column = null;
if (cols.getLength() > j)
{
column = TableColElement.as(cols.getItem(j));
}
else
{
column = cge.appendChild(Document.get().createColElement());
}
column.setWidth(widths.get(j)+"px");
}
}
}
4
您可以使用addColumnStyleName(int index, java.lang.String styleName)
方法为特定列使用样式名称。
-2
为CellTable的GWT文档涵盖了这一点,请参见: http://www.gwtproject.org/doc/latest/DevGuideUiCellTable.html
在 “控制列宽”。
0
我的工作是在我的css中添加一个新类。此类仅适用于选择长度因数据而异的元素。
.__gwt_cell select{
width:170px;
}
然后将它放在我的特别单元格样式像○:
table.getColumn(3).setCellStyleNames("yourstyle");
相关问题
- 1. 在GWT 2.2 CellTable中设置列的宽度而不剪切TextInputCell?
- 2. gwt 2.4 DataGrid - 自动设置列宽?
- 3. GWT CellTable wordwrap
- 4. Celltable GWT排序
- 5. GWT CELLTABLE:如何设置celltable header上的降序图标?
- 6. GWT Celltable reset
- 7. GWT CellTable排序
- 8. GWT RequestFactory + CellTable
- 9. GWT CellTable样式
- 10. GWT样式CellTable标头
- 11. GWT CellTable验证
- 12. CELLTABLE在GWT
- 13. GWT CellTable与ImageResourceCell
- 14. GWT 2.4 CellTable问题
- 15. CellTable中的GWT填充行
- 16. GWT:在TabPanel里面的FlowPanel中的CellTable
- 17. GWT 2.1 CellTable列标题点击事件
- 18. GWT CellTable/DataGrid - 如何检测列选择?
- 19. GWT CellTable列调整大小/排序
- 20. GWT CELLTABLE列的单元值更新
- 21. GWT CellTable - 根据行添加列
- 22. 将行号列添加到GWT CellTable
- 23. GWT CellTable排序列自定义头
- 24. Gwt celltable在列上调用排序
- 25. 设置列宽
- 26. CellTable GWT RPC匹配数据
- 27. GWT CellTable和编辑框架
- 28. GWT - 使CellTable Cell使用HTML?
- 29. GWT - CellTable/DataGrid使用ImageCell
- 30. GWT可拖动CellTable单元格
我知道的不知道如何使用它这个方法。这样的风格类应该在哪里宣布? – Opal 2010-12-16 15:40:19
在您的应用程序的样式表中。查看[ClientBundle](http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideClientBundle.html)或者只包含一个自定义样式表。 – bestform 2010-12-16 15:58:34
谢谢,它的工作原理。我想在CellTable.Resource中声明这个样式表,但我得到一个异常:[错误]无法处理CSS。你知道它是如何做到的吗? – Opal 2010-12-16 16:09:44