grouping-ungrouping in grid

asked 2010-06-29 13:14:32 +0800

kapil4ya gravatar image kapil4ya
172 2

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

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-06-29 15:54:49 +0800

vinhvo gravatar image vinhvo
369 3

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.

link publish delete flag offensive edit

answered 2010-06-29 22:45:21 +0800

kapil4ya gravatar image kapil4ya
172 2

Thanks for the reply, vinhvo, do you have a sample code or something which illustrates what you are talking about ?

Thank you.

link publish delete flag offensive edit

answered 2010-06-30 02:07:37 +0800

vinhvo gravatar image vinhvo
369 3
<?page title="Auto Generated index.zul"?>
<window title="Hello World!!" border="normal" width="100%" apply="test.vinhvo.Controller" id="win" >


	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);

	<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"/>
			<group label="Dell"/>
				<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"/>
				<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"/>				
				<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"/>				
			<group label="Compaq"/>
				<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"/>				
				<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"/>				
			<groupfoot spans="5">
				<label value="This a summary about Compaq Desktop PCs"/>
	<button id="Ungrid" label="Ungrid"></button>
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){
	public void onClick$Ungrid(Event evt){
		Rows rows=myGrid.getRows();
		int i=0;
		for(Object obj : rows.getChildren()){
		int k=0;
		for(Integer in : index){

Just quick hack to give you an idea. I am sure you can write much nicer code. BR, VinhVo.
link publish delete flag offensive edit

answered 2010-06-30 06:05:36 +0800

kapil4ya gravatar image kapil4ya
172 2

Thanks VinhVo,

That's what I needed, will just now create a new popup and will replicate the functionality provided by the default one and add this ungrid functionality.

link publish delete flag offensive edit
Your reply
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: 2010-06-29 13:14:32 +0800

Seen: 356 times

Last updated: Jun 30 '10

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