-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Is it possible to have un-grouping of the grid columns, the demo shows only the grouping but not ungrouping.
I suppose, I will have to create custom menupopup but then how to proceed from there?
Thank you
I think we can get the group component by id and then detach it. Or we can iterate through all the children of grid and check if the class of that children is zk.ui.group then we can detach all of grid component.
<?page title="Auto Generated index.zul"?> <window title="Hello World!!" border="normal" width="100%" apply="test.vinhvo.Controller" id="win" > <zk> <zscript> class Comp implements Comparator { private boolean _asc; public Comp(boolean asc) { _asc = asc; } public int compare(Object o1, Object o2) { String s1 = o1.getChildren().get(0).getValue(), s2 = o2.getChildren().get(0).getValue(); int v = s1.compareTo(s2); return _asc ? v: -v; } } Comp asc = new Comp(true), dsc = new Comp(false); </zscript> <grid fixedLayout="true" id="myGrid"> <columns sizable="true"> <column label="Brand" sortAscending="${asc}" sortDescending="${dsc}"/> <column label="Processor Type" width="150px"/> <column label="Memory (RAM)" width="120px"/> <column label="Price" width="100px"/> <column label="Hard Drive Capacity" width="150px"/> </columns> <rows> <group label="Dell"/> <row> <label style="padding-left:15px" value="Dell E4500 2.2GHz"/> <label value="Intel Core 2 Duo"/> <label value="2GB RAM"/> <label value="$261.00" style="color:green"/> <label value="500GB"/> </row> <row> <label style="padding-left:15px" value="XP-Pro Slim Dell-Inspiron-530-s"/> <label value="Intel Core 2 Duo"/> <label value="2GB RAM"/> <label value="$498.93" style="color:green"/> <label value="500GB"/> </row> <row> <label style="padding-left:15px" value="Dell P4 3.2 GHz"/> <label value="Intel Pentium 4"/> <label value="4GB RAM"/> <label value="$377.99" style="color:green"/> <label value="500GB"/> </row> <group label="Compaq"/> <row> <label style="padding-left:15px" value="Compaq SR5113WM"/> <label value="Intel Core Duo"/> <label value="1GB RAM"/> <label value="$279.00" style="color:green"/> <label value="160GB"/> </row> <row> <label style="padding-left:15px" value="Compaq HP XW4200"/> <label value="Intel Pentium 4"/> <label value="4GB RAM"/> <label value="$980" style="color:green"/> <label value="500GB"/> </row> <groupfoot spans="5"> <label value="This a summary about Compaq Desktop PCs"/> </groupfoot> </rows> </grid> <button id="Ungrid" label="Ungrid"></button> </zk> </window>
package test.vinhvo; import java.util.ArrayList; import java.util.List; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zul.Grid; import org.zkoss.zul.Group; import org.zkoss.zul.Rows; public class Controller extends GenericForwardComposer { Grid myGrid; List<Integer> index= new ArrayList<Integer>(); public void onCreate$win(Event evt){ System.out.println(System.currentTimeMillis()); } public void onClick$Ungrid(Event evt){ Rows rows=myGrid.getRows(); int i=0; for(Object obj : rows.getChildren()){ if(obj.getClass().equals(Group.class)){ index.add(i); System.out.println(i); } i++; } int k=0; for(Integer in : index){ ((Component)rows.getChildren().get(in-k)).detach(); k++; } myGrid.invalidate(); } }
Asked: 2010-06-29 13:14:32 +0800
Seen: 356 times
Last updated: Jun 30 '10