2013-02-14 135 views
1

我正在實現一個同時具有colspan和rowspan單元的表。我之前使用過FlexTable,但決定使用CellTable。但它看起來像CellTable不支持添加風格,同時也FlexTable ...請看看圖片就知道我想要做的事:CellTable中的Colspan和Rowspan

任何建議都歡迎。

回答

1

您可以使用AbstractCellTableBuilder來渲染自己的結構。
看看Custom DataGrid showcase

+0

在*自定義DataGrid展示*,你能解釋我'TableRowBuilder tr = startRow();'? startRow()方法的定義是什麼?我找不到。謝謝 – Cataclysm 2014-06-14 08:24:22

+0

@Cataclysm:它在超類中:請參見[AbstractHeaderOrFooterBuilder](http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/cellview/client/AbstractHeaderOrFooterBuilder.html#startRow()) – 2016-06-28 07:35:52

-2
; 
    FlexTable table = new FlexTable(); 
    FlexTable.FlexCellFormatter flexCellFormatter =table.getFlexCellFormatter(); 
    flexCellFormatter.setColSpan(3,0,2); 
    final TextBox textBox = new TextBox(); 
    Label label = new Label(); 
    label.setText("Name"); 
    table.setWidget(0, 0, label); 
    table.setWidget(0, 1, textBox); 
    final TextBox textBox1 = new TextBox(); 
    Label label1 = new Label(); 
    label1.setText("Surname"); 
    table.setWidget(1,0,label1); 
    table.setWidget(1, 1, textBox1); 
    final TextBox textBox2 = new TextBox(); 
    Label label2 = new Label(); 
    label2.setText("e-mail"); 
    table.setWidget(2,0, label2); 
    table.setWidget(2, 1, textBox2); 

    Button button = new Button("apply", new ClickHandler() { 
     @Override`` 
     public void onClick(ClickEvent event) { 
      String name = textBox.getText(); 
      String surname = textBox1.getText(); 
      Window.alert("Your name is " + name + "Your surname is " + surname); 
     } 
    }); 
    table.setWidget(3, 0, button);//Write this code, then run, you can answer! goodLuck :-)) 
+0

CellTable。不FlexTable。 – Cataclysm 2014-06-14 08:22:29