how to insert "after" a component? (向指定控件后面插入一个兄弟控件)

asked 2019-06-17 19:37:27 +0800

xuesong gravatar image xuesong
101 1

updated 2019-06-19 10:18:20 +0800

cor3000 gravatar image cor3000
5225 2 7
ZK Team

实例如下,现在想在txt2控件后插入一个div,请问可以实现吗? 目前ZK提供的方法有appendChild、beforeChildAdded、insertBefore,无法实现。

<textbox id="txt1"/>
<textbox id="txt2"/>
<textbox id="txt3"/>

EDIT: (google translation) The example is as follows, now I want to insert a div after the txt2 control, can I achieve it?

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted

answered 2019-06-18 14:23:08 +0800

cor3000 gravatar image cor3000
5225 2 7
ZK Team

updated 2019-06-19 09:29:17 +0800

As shown in this example you can add a component after another one, by inserting it before its next sibling. You have to call the method from the parent component:

txt2.getParent().insertBefore(new Label("inserted"), txt2.getNextSibling())


If the nextsibling doesn't exist it will return null. Calling parent.insertBefore(comp, null) is equivalent to calling parent.appendChild(comp), both will append to the end. In your example after txt3

Please also refer to the related java docs:


link publish delete flag offensive edit



xuesong ( 2019-06-18 22:36:16 +0800 )edit

replied above...

cor3000 ( 2019-06-19 09:29:44 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2019-06-17 19:37:27 +0800

Seen: 25 times

Last updated: Jul 30 '19

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More