[英]merge column header in DataGrid or cellTable in GWT 2.4
I want to know the workaround used to have colspan in DataGrid or CellTable 我想知道以前在DataGrid或CellTable中使用colspan的解决方法
I saw the the GWT showcase : http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCustomDataGrid 我看到了GWT展示柜: http : //samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCustomDataGrid
but there is no TableRowBuilder and AbstractHeaderOrFooterBuilder in GWT 2.4 但GWT 2.4中没有TableRowBuilder和AbstractHeaderOrFooterBuilder
I also found that CellTableBuilder API is good too to this purpose but it's not available in GWT 2.4 我还发现CellTableBuilder API对此也很好,但是在GWT 2.4中不可用
So I want to know if there is another trick to merge columns header in GWT 2.4 ? 所以我想知道是否还有另一个技巧可以在GWT 2.4中合并列标题?
Or how to get the column header using the DOM ? 还是如何使用DOM获取列标题?
Here is what I've done to solve this problem in GWT 2.4. 这是我为解决GWT 2.4中的此问题所做的工作。
I've used DOM like this 我已经这样使用过DOM
Element thead = view.datagrid.getElement().getElementsByTagName("thead").getItem(0);
Element tr;
tr = thead.getElementsByTagName("tr").getItem(0);
for (int i = 0; i < tr.getChildCount(); i++) {
Element th = tr.getElementsByTagName("TH").getItem(i);
String headerText = th.getInnerHTML();
String sortHeader = "";
String colspanValue = th.getAttribute("colspan");
if (th.getChildCount() == 1) {
Element div = th.getElementsByTagName("DIV").getItem(0);
sortHeader = null != div ? div.getElementsByTagName("DIV").getItem(1).getInnerHTML()
: "";
}
if (sortHeader.equalsIgnoreCase("COLUMHEADER1") && colspanValue.equals("1")) {
th.setAttribute("colspan", "2");
Element thNext = tr.getElementsByTagName("TH").getItem(i + 1);
thNext.setAttribute("style", "display: none !important");
}
} }
and for the first start I've used a timer (1sec is the min) like this 对于第一次启动,我使用了这样的计时器(最少1秒)
new Timer() {
@Override
public void run() {
view.datagrid.setVisible(true);
//call to merge column code or function
}
}.schedule(1000);
"view." “视图。” is used because the main class is a presenter 之所以使用,是因为主类是主持人
EDIT: display:none is used for the sort issue 编辑:显示:无用于排序问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.