ZK中如何在特定位置添加多个<row>个组件

How to add many <row> components in ZK in specific position

我在 ZK 应用程序中工作,我需要根据用户输入添加 <row> 的组件。 zul是这样的:

<grid id="mygrid">
    <rows id="rows">
        <row>
            <cell>
                <label value="Rows to add 1:"/>
            </cell>
            <cell>
                <textbox id="txt_addRows1"/>
            </cell>
        </row>

        <!-- Here I need to add rows specified in txt_addRows1 -->

        <row>
            <cell>
                <label value="Rows to add 2:"/>
            </cell>
            <cell>
                <textbox id="txt_addRows2"/>
            </cell>
        </row>

        <!-- Here I need to add rows specified in txt_addRows2 -->

        <row align="right">
            <cell colspan="2">
                <button id="btn_generate" label="Generate"/>
            </cell>
        </row>
    </rows>
</grid>

在 composer 中我可以做类似的事情:

Row someRow = new Row();
row.setParent(rows);

我的问题是:如何指定新行(在 composer 中以编程方式生成)在指定位置而不是其他位置呈现?

也欢迎任何suggestion/guide。预先感谢您的回答。

有两种方法可以在 DOM 中插入内容。
第一种方式是设置父级,第二种方式是添加子级。

如果勾选AbstractComponent api。你看他们也说 appendChildinsertBefore(Component newChild, Component refChild)

所以代码看起来像:

rows.insertBefore(newRow,rowWhatComesAfterYourRow);