IDEMPIERE-179 Zk6: Implement collapsible group for grid

This commit is contained in:
Elaine Tan 2012-03-30 18:25:20 +08:00
parent 9f3f447d27
commit 9f2d232f75
2 changed files with 19 additions and 9 deletions

View File

@ -56,9 +56,12 @@ public class Group extends org.zkoss.zul.Group {
throw new UiException("Unsupported child for setLabel: "+cell); throw new UiException("Unsupported child for setLabel: "+cell);
} }
public void setOpen(boolean open) { public void setOpen(boolean open) {
if(getParent() == null && !open)
open = true; // force the group to open when the parent is null
super.setOpen(open); super.setOpen(open);
autoFirstCell().setOpen(open); autoFirstCell().setOpen(isOpen());
if(getParent() != null) if(getParent() != null)
{ {
@ -69,11 +72,11 @@ public class Group extends org.zkoss.zul.Group {
String value = (String) row.getAttribute(GROUP_ROW_VISIBLE_KEY); String value = (String) row.getAttribute(GROUP_ROW_VISIBLE_KEY);
if (value != null) if (value != null)
visible = value.equals("true"); visible = value.equals("true");
row.setVisible(open && visible); row.setVisible(isOpen() && visible); // hide the row of the children when group is not open
} }
} }
} }
public class GroupHeader extends Div implements EventListener<Event> public class GroupHeader extends Div implements EventListener<Event>
{ {
/** /**
@ -84,7 +87,7 @@ public class Group extends org.zkoss.zul.Group {
private Label lbl; private Label lbl;
private String title; private String title;
private boolean isOpen; private boolean open;
public GroupHeader() public GroupHeader()
{ {
@ -116,12 +119,12 @@ public class Group extends org.zkoss.zul.Group {
} }
public boolean isOpen() { public boolean isOpen() {
return isOpen; return open;
} }
public void setOpen(boolean isOpen) { public void setOpen(boolean open) {
this.isOpen = isOpen; this.open = open;
img.setSclass(this.isOpen ? "z-group-img-open" : "z-group-img-close"); img.setSclass(this.open ? "z-group-img-open" : "z-group-img-close");
} }
@Override @Override

View File

@ -490,7 +490,14 @@ tr.z-group td.z-row-inner {
font-weight: bold; font-weight: bold;
} }
div.z-group-cnt {
display:table-cell;
vertical-align:middle;
}
div.z-group-cnt span.z-label { div.z-group-cnt span.z-label {
display:inline-block;
vertical-align:middle;
color: #2C559C; color: #2C559C;
padding: 5px; padding: 5px;
width: auto; width: auto;