Defining GWT CellTables with UiBinder

前端 未结 1 616
执念已碎
执念已碎 2021-02-15 02:26

If I define my CellTable in MyView.ui.xml UiBinder file like this:



        
相关标签:
1条回答
  • 2021-02-15 03:16

    Evidently, in the second listing you're trying to add a column as a child object. Cell table doesn't accept children directly (meaning there is no addChild(...) method).

    If you have fixed number of columns and want to use UIBinder consider using mere HTML table. In that case you will have all columns in the XML file, but the table will become harder to work with - HtmlElement not Widget.

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

    And the code might look like the following

    ... 
    @UiField
    private TableColElement firstColumn;
    
    @UiField
    private TableColElement secondColumn;
    

    But all other operations with the table will be via DOM. Like table.appentChild(rowElement). I think doing like this doesn't worth it.

    0 讨论(0)
提交回复
热议问题