如何添加许多< row> ZK中特定位置的组件 [英] How to add many <row> components in ZK in specific position
问题描述
我在ZK应用程序中工作,我需要根据用户输入添加<row>
的组件.祖尔是这样的:
I'm working in a ZK application and I need to add <row>
's components based on user input. The zul is like this:
<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>
在作曲家中,我可以做类似的事情:
In the composer I can do something like:
Row someRow = new Row();
row.setParent(rows);
我的问题是:我如何指定新行(在作曲家中以编程方式生成)在指定位置而不是其他位置呈现?
My question is: how do I specify that the new row (generated programmatically in the composer) to be rendered in the specified places and not others?
也欢迎任何建议/指南.预先感谢您的回答.
Any suggestion/guide is also welcomed. Thanks in advance for your answers.
推荐答案
有两种方法可以在DOM中插入内容.
第一种方法是设置父级,第二种方法是添加一个子级.
There are 2 ways to insert something in the DOM.
First way is to set the parent, the second one is adding a child.
如果您检查 AbstractComponent
api .您会看到他们也谈到appendChild
和insertBefore(Component newChild, Component refChild)
If you check the AbstractComponent
api. you see they also speak of appendChild
and insertBefore(Component newChild, Component refChild)
所以代码看起来像:
rows.insertBefore(newRow,rowWhatComesAfterYourRow);
这篇关于如何添加许多< row> ZK中特定位置的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!