合并 DataGrid 中的列 header 或 GWT 2.4 中的 cellTable

merge column header in DataGrid or cellTable in GWT 2.4

我想知道在 DataGrid 或 CellTable 中使用 colspan 的解决方法

我看到了 GWT 展示柜:http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCustomDataGrid

但是 GWT 2.4 中没有 TableRowBuilder 和 AbstractHeaderOrFooterBuilder

我还发现 CellTableBuilder API 也适用于此目的,但它在 GWT 2.4 中不可用

所以我想知道在 GWT 2.4 中是否还有其他合并列 header 的技巧?

或者如何使用 DOM 获取列 header ?

这是我在 GWT 2.4 中解决这个问题的方法。

我用过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");
        }

}

第一次开始时,我使用了这样的计时器(最小值为 1 秒)

 new Timer() {
        @Override
        public void run() {
            view.datagrid.setVisible(true);
            //call to merge column code or function
        }
    }.schedule(1000);
使用

"view."是因为主要class是主持人

编辑: display:none用于排序问题