2013-03-02 84 views
1

我正在尝试使用Wicket显示表格。我使用Panel来创建表格,并使用PropertyColumns来添加列。在Wicket中创建表格

如何将几个列组合为一个列。

+0

所有我想要做的是有一组列的常见标题。 – sweetcode 2013-03-02 13:51:56

+0

也许尝试添加您试图呈现的HTML的最终状态,因为它不是很清楚您正在尝试完成什么 – ZeusSelerim 2013-03-02 15:49:16

+0

啊!我试图放置表格的图像,但我的名誉点阻止了我做这一点。 让我稍微详细地解释什么,我想。 我的表中有2列,产品和单元测试。 我想除法单元两个部分,通过和失败的测试列。 我能创建一个包含两列的表格我正在生成以下列: 列表 columnList = new ArrayList(); columnList.add(new PropertyColumn (new Model(“Product”),“prod uctName“,”productName“); (新模型(“单元测试”),null,null); – sweetcode 2013-03-02 18:10:04

回答

4

看来您正在使用DataTable或后代。对于你的情况,我会使用一个ListView,你可以更容易地控制输出HTML。

在HTML:

<table> 
    <thead> 
    <tr> 
     <th rowspan="2">Product</th> 
     <th colspan="2">Unit tests</th> 
    </tr> 
    <tr> 
     <th>Passed</th> 
     <th>Failed</th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr wicket:id="listView"> 
     <td wicket:id="productComponent">Product</td> 
     <td wicket:id="passedComponent">PassedColumn</td> 
     <td wicket:id="failedComponent">FailedColumn</td> 
    </tr> 
    </tbody> 

在Java:

add(new ListView<SomeDetails>("listView", listData) 
{ 
     public void populateItem(final ListItem<SomeDetails> item) 
     { 
       final SomeDetails data= item.getModelObject(); 
       item.add(new Label("productComponent", data.getProduct())); 
       item.add(new Label("passedComponent", data.getPassed())); 
       item.add(new Label("failedComponent", !data.getPassed())); 
     } 
}); 
+1

我认为您的检票ID应该位于tr元素上,而不是tbody元素 – 2014-02-28 22:58:33

+0

Pappin如果id位于tbody标签上,则每个SomeDetails项目都会重复。 – Kiril 2014-03-05 18:22:04