-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi All.
How can I insert a new row in already existing grid after a given row?
The scenario is tht I have certain number of rows in a grid and one of the row has a toolbarbutton,on click of which a new row has to be inserted just after that particular row.
Use of append() method will add the row to last of the grid so I can't use it.Is there any way insertBefore() can be used in this scenario.
Plz note tht I only hav the row which has the toolbarbutton.
Any kind of help will be appreciated...
Hi,
you can use a combination of parent and nextSibling:
<zk> <grid> <rows> <row><label value="A"/></row> <row id="target"><label value="B"/></row> <row><label value="D"/></row> </rows> </grid> <zscript> Row row = new Row(); row.appendChild(new Label("C")); target.getParent().insertBefore(row, target.getNextSibling()); </zscript> </zk>
HTH, Maik
Thanks for help...
The reference manual for insertBefore(Component newChild, Component refChild) says tht if refChild is null then in tht case, new row will be appended to the end but in my case its shouting for NullPointerException.I am using following syntax:
targetRow.getParent().insertBefore(newrow,targetRow.getNextSibling());
it works fine if there exists a row after the targetRow otherwise throw NullPonterException
Hi,
which ZK version do you use? I've just tried my example in the ZK-Sandbox (running 5.0.5) without row "D" and it works as expected.
Cheers, Maik
Hi Maik.
I got where the problem was...
I was not properly addressing the targetRow coz of which NullPointerException was being thrown.
Nyways thanks..
Asked: 2010-12-23 05:19:26 +0800
Seen: 746 times
Last updated: Dec 24 '10