使用UiBinder定义GWT单元表

使用UiBinder定义GWT单元表,gwt,uibinder,celltable,gwt-celltable,Gwt,Uibinder,Celltable,Gwt Celltable,如果我在MyView.ui.xml UiBinder文件中定义我的CellTable,如下所示: <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:c="urn:import:com.google.gwt.user.cellview.client" ui:generateFormat='com.google.gwt.i

如果我在MyView.ui.xml UiBinder文件中定义我的CellTable,如下所示:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:c="urn:import:com.google.gwt.user.cellview.client"
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys='com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator'
ui:generateLocales='default' xmlns:p1="urn:import:com.google.gwt.user.cellview.client">
        ...
    <g:HTMLPanel>           
      <c:CellTable
        addStyleNames='{style.cellTable}'
        pageSize='15'
        ui:field='cellTable' width="100%">  
       </c:CellTable>           
    </g:HTMLPanel>

...
然后编程我将列添加到CellTable中,一切正常

但是为了减少样板代码,我还想在UiBinder文件中定义表列。我试过这个:

    ...
    <g:HTMLPanel>           
      <c:CellTable
        addStyleNames='{style.cellTable}'
        pageSize='15'
        ui:field='cellTable' width="100%">  
            <c:TextColumn 
                addStyleNames='{style.titleColumn}'
                ui:field="titleColumn"/>
       </c:CellTable>           
    </g:HTMLPanel>
。。。
但它会产生以下错误:

[错误][辩证法]-找到意外的子元素元素addStyleName='{style.titleColumn}'ui:field='titleColumn'>(:33)


如何使用UiBinder定义整个CellTable?

显然,在第二个列表中,您试图添加一列作为子对象。单元格表不直接接受子项(意味着没有addChild(…)方法)

如果您有固定数量的列,并且希望使用UPBIDER,则只需使用HTML表即可。在这种情况下,您将在XML文件中拥有所有列,但使用-HtmlElement而不是Widget将使该表变得更加困难

<table ui:field="table">
    <col ui:field="firstColumn" class="{style.firstColumn}">
    <col ui:field="secondColumn"  class="{style.secondColumn}">
    ...
</table>

但是表的所有其他操作都将通过DOM进行。比如table.appentChild(rowElement)。我认为这样做不值得。

你用CellTable解决了这个问题吗?
... 
@UiField
private TableColElement firstColumn;

@UiField
private TableColElement secondColumn;