【问题标题】:merge column header in DataGrid or cellTable in GWT 2.4在 GWT 2.4 中合并 DataGrid 或 cellTable 中的列标题
【发布时间】:2015-07-14 18:01:13
【问题描述】:

我想知道在 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 中合并列标题是否还有其他技巧?

或者如何使用 DOM 获取列标题?

【问题讨论】:

    标签: java gwt datagrid mvp4g


    【解决方案1】:

    这是我在 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);
    

    “查看。”之所以使用,是因为主类是演示者

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

    【讨论】:

      猜你喜欢
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 2011-09-20
      • 2012-06-08
      • 1970-01-01
      相关资源
      最近更新 更多