如何以编程方式在ZK / Zul中添加colspan?

时间:2013-02-07 09:06:10

标签: zk zul

如何在ZUL框架中设置colspan的属性?

e.g。

Tr tr = new Tr();

Td td = new Td();

tr.appendChild(td);


td = new Td();

tr.appendChild(td);

现在,在下一行中,我必须通过作曲家在表格行中放置单个td,这将覆盖两个td的空间。我怎么能做到这一点?

<Table>
    <tr>
      <td>
      </td/>
       <td>
       </td>
    </tr>
    <tr>
      <td colspan="2">
      </td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:3)

在ZUL中,这不是使用<table><tr><td>标记,而是<grid><row><cell>标记。像这样......

<grid>
    <columns>
        <column label="A" />
        <column label="B" />
    </columns>
    <rows>
        <row>
            <cell>
                <label value="item 1" />
            </cell>
            <cell>
                <label value="item 2" />
            </cell>
        </row>
        <row>
            <cell colspan="2">
                <label value="item 3" />
            </cell>
        </row>
    </rows>
</grid>

从Java方面来说,这变得容易了..

Grid grid = new Grid();
Rows rows = new Rows();
rows.setParent(grid);
Row row1 = new Row();
row1.setParent(rows);
Cell cell1 = new Cell();
cell1.setParent(row1);
cell1.appendChild(new Label("item1"));
Cell cell2 = new Cell();
cell2.setParent(row1);
cell2.appendChild(new Label("item2"));
Row row2 = new Row();
row2.setParent(rows);
Cell cell3 = new Cell();
cell3.setParent(row2);
cell3.appendChild(new Label("item3"));
cell3.setColspan(2); // this is what you're looking for

有关详细信息,请参阅(好)ZK docs