Processing...

Suggested case list:

Using timer to refresh a grid

383guest172.69.33.12125nk0uiMay 7, 2020 7:23:47 AMlink

user model to move item to another listbox

120guest162.158.193.148d0n3krApr 2, 2020 5:28:28 AMlink

Disabled list item row passed to VM-1981

296fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:44 PMlink

Disabled list item row passed to VM-1981

295fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:16 PMlink

Disabled list item row passed to VM-1981

294fatih123160.83.36.13225nk0uiFeb 13, 2018 3:30:44 PMlink

grid sample with ListModel/RowRenderer

816guest80.82.2.1312vah9ajFeb 21, 2017 11:42:21 AMlink

grid sample with ListModel/RowRenderer

809guest175.98.113.1622vah9ajJan 26, 2017 9:19:33 AMlink

grid sample with ListModel/RowRenderer

196guest79.185.142.402vah9ajApr 26, 2014 10:53:57 PMlink

grid sample with ListModel/RowRenderer

195guest79.185.142.402vah9ajApr 26, 2014 10:53:54 PMlink

grid sample with ListModel/RowRenderer

194guest79.185.142.402vah9ajApr 26, 2014 10:53:51 PMlink

grid sample with ListModel/RowRenderer

193guest79.185.142.402vah9ajApr 26, 2014 10:53:48 PMlink

grid sample with ListModel/RowRenderer

192guest79.185.142.402vah9ajApr 26, 2014 10:53:44 PMlink

grid sample with ListModel/RowRenderer

191guest79.185.142.402vah9ajApr 26, 2014 10:53:40 PMlink

Hierarchy table without using ZK PE/EE

1aaknai151.28.135.2131s871daJul 29, 2013 11:02:46 PMlink

grid sample with ListModel/RowRenderer

128aaknai151.28.135.2132vah9ajJul 29, 2013 7:20:00 PMlink

user model to move item to another listbox

1TonyQ114.25.109.94d0n3krApr 21, 2012 10:43:27 AMlink

Using timer to refresh a grid

1TonyQ220.133.44.3725nk0uiFeb 17, 2012 3:17:34 AMlink

Fire a event from child iframe

1TonyQ220.133.44.372eupjotFeb 3, 2012 5:04:52 AMlink

Textbox input restriction sample

1TonyQ72.21.245.2431b3nlr0Dec 20, 2011 10:09:10 AMlink

Test web core taglib in ZUL

1TonyQ198.203.175.175ofqkemDec 17, 2011 3:36:08 AMlink

Latest 10 Fiddles :

combobox long comboitem

4guest108.162.221.13617ljsinJun 13, 2024 7:41:58 AMlink

search box

1guest162.158.178.591td9gqbJun 13, 2024 1:56:31 AMlink

Messagebox progress bar

1guest162.158.129.1862331bsuJun 11, 2024 10:12:09 PMlink

Vflex

39guest172.70.134.752vd369jJun 11, 2024 8:55:42 PMlink

Vflex

38guest172.70.34.882vd369jJun 11, 2024 8:54:26 PMlink

Vflex

37guest172.70.34.882vd369jJun 11, 2024 8:54:21 PMlink

Vflex

36guest172.70.34.882vd369jJun 11, 2024 8:54:21 PMlink

Vflex

35guest172.70.34.882vd369jJun 11, 2024 8:54:20 PMlink

flex broken zk 10

1guest172.69.135.201uue6c5Jun 11, 2024 4:46:35 PMlink

Another new ZK fiddle

6guest172.69.192.2103tip2nmJun 10, 2024 11:24:07 AMlink

grouped-list

5guest141.101.68.9837afusnJun 9, 2024 2:57:08 PMlink

resources

index.zulzul<zk> <window apply="pkg$.TestComposer" vflex="1"> <grid id="grid" vflex="1" span="true"> <custom-attributes org.zkoss.zul.grid.rod="true"/> <custom-attributes org.zkoss.zul.grid.preloadSize="100" /> <custom-attributes org.zkoss.zul.grid.initRodSize="50" /> <custom-attributes org.zkoss.zul.grid.autoSort="ignore.change"/> <columns> <column hflex="min" label="A" id="col1" sortDirection="ascending" iconSclass="z-icon-group" /> <column hflex="min" label="B" id="col2"/> <column hflex="min" label="C" id="col3" align="right" /> <column hflex="min" label="Group" id="col4"/> </columns> <foot> <footer /> <footer id="foot2" /> <footer id="foot3" /> </foot> <auxhead> <auxheader colspan="3"> <label id="counter" /> </auxheader> <auxheader colspan="1"> <toolbarbutton label="Gruppieren nach"/> </auxheader> </auxhead> <!--auxhead> <auxheader colspan="3"> <groupbox> <caption label="group action"/> <button label="Click me" iconSclass="z-icon-check"/> </groupbox> </auxheader> </auxhead--> </grid> </window> </zk> TestComposer.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import pkg$.*; public class TestComposer extends GenericForwardComposer{ private static final long serialVersionUID = 3120643218344891700L; private final static int NUMBER_OF_GROUPS = 2000; private final static int APPROXIMATE_MIN_GROUP_SIZE = 3000; private final static int APPROXIMATE_MAX_GROUP_SIZE = 5000; private Grid grid; private Column col1; private Column col2; private Footer foot2; private Footer foot3; private Label counter; private List<MyItem> itemList; public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); col1.setSortAscending(new ColumnOneComparator()); col1.setSortDescending(new ColumnOneComparator().reversed()); col2.setSortAscending(new ColumnTwoComparator()); col2.setSortDescending(new ColumnTwoComparator().reversed()); final MyRowRenderer renderer = new MyRowRenderer(); renderer.registerGroupToggle(this); grid.setRowRenderer(renderer); ListModelList<MyItem> model = new ListModelList<>(); grid.setModel(model); // loading asynchronously model.addAll(getData()); int sum = 0; for (MyItem item: itemList) { if (item.isGroup()) { sum += item.getSum(); } } foot2.appendChild(new Label("Summe: ")); foot2.setAlign("right"); foot3.appendChild(new Label(String.valueOf(sum))); counter.setValue("Einträge: " + itemList.size()); } private List<MyItem> getData() { List<MyItem> groups = new ArrayList<>(NUMBER_OF_GROUPS); for (int i = 0; i < NUMBER_OF_GROUPS; i++) { groups.add(new MyItem("group " + i)); } ArrayList<MyItem> list = new ArrayList<>(groups); itemList = new ArrayList<>(); int limit = NUMBER_OF_GROUPS * APPROXIMATE_MAX_GROUP_SIZE; int offset = randomInt(APPROXIMATE_MIN_GROUP_SIZE, APPROXIMATE_MAX_GROUP_SIZE); int group = 0; for (int i = 0; i < limit; i++) { list.add(new MyItem(groups.get(group), "a" + (limit - i), new String(new char[(int) (Math.random() * 5)]).replace("\0", "b") + i, i)); if (i > offset) { if (++group >= NUMBER_OF_GROUPS) { group--; offset = limit; } else { offset += randomInt(APPROXIMATE_MIN_GROUP_SIZE, APPROXIMATE_MAX_GROUP_SIZE); } } } this.itemList = new ArrayList<>(list); return list; } private int randomInt(int min, int max) { int result = -1; while(result < min) { result = (int) (Math.random() * max); } return result; } public void toggleGroup(MyItem item) { item.setCollapsed(!item.isCollapsed()); updateModel(); } private void updateModel() { List<MyItem> newList = new ArrayList<>(itemList); newList.removeIf(item -> !item.isGroup() && item.getGroup().isCollapsed()); grid.setModel(new ListModelList<>(newList)); } } MyItem.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import pkg$.*; public class MyItem extends GenericForwardComposer { public MyItem group; public boolean collapsed; public String v1; public String v2; public int v3; private List<MyItem> children = new ArrayList<>(); public MyItem(MyItem group, String v1, String v2, int v3) { this(v1, v2, v3); this.group = group; group.register(this); } public MyItem(String v1) { this(v1, null, 0); } public MyItem(String v1, String v2, int v3) { this.v1 = v1; this.v2 = v2; this.v3 = v3; } boolean isGroup() { return group == null; } void register(MyItem item) { children.add(item); } public int getSum() { if (!isGroup()) { return -1; } int result = 0; for (MyItem item : children) { result += item.v3; } return result; } public void setCollapsed(boolean collapsed) { this.collapsed = collapsed; } public boolean isCollapsed() { return collapsed; } public int compareTo(MyItem o) { return new ColumnOneComparator().compare(this, o); } public MyItem getGroup() { return group; } } MyRowRenderer.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import org.zkoss.zhtml.I; public class MyRowRenderer implements RowRenderer<Object> { private TestComposer composer; public void render(final Row row, final Object data, int index) { final MyItem item = (MyItem) data; if (item.isGroup()) { row.setStyle("background:#6f6f6f;color:#fff;font-weight:bold;cursor:pointer"); Cell cell1 = createCell(row, new Label(" " + item.v1)); createCell(row, new Label("")); I icon = new I(); cell1.insertBefore(icon, cell1.getFirstChild()); if (item.isCollapsed()) { icon.setSclass("z-icon-chevron-down"); } else { icon.setSclass("z-icon-chevron-up"); } createCell(row, new Label(String.valueOf(item.getSum()))); createCell(row, new Label("")); row.addEventListener(Events.ON_CLICK, evt -> composer.toggleGroup(item)); } else { createCell(row, new Label(item.v1)); createCell(row, new Label(item.v2)); createCell(row, new Label(String.valueOf(item.v3))); createCell(row, new Label(item.group.v1)); } } void registerGroupToggle(TestComposer composer) { this.composer = composer; } private Cell createCell(Row row, Label label) { return createCell(row, label, null); } private Cell createCell(Row row, Label label, String style) { Cell cell = new Cell(); cell.setParent(row); cell.appendChild(label); if (style != null) { cell.setStyle(style); } return cell; } } ColumnComparator.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import pkg$.*; public class ColumnComparator extends GenericForwardComposer implements Comparator<MyItem> { private final boolean reversed; private final Comparator<MyItem> itemComparator; public ColumnComparator(Comparator<MyItem> itemComparator) { this(itemComparator, false); } private ColumnComparator(Comparator<MyItem> itemComparator, boolean reversed) { this.reversed = reversed; this.itemComparator = itemComparator; } public int compare(MyItem o1, MyItem o2) { return compareWithGroups(o1, o2); } public final Comparator<MyItem> reversed() { return new ColumnComparator(itemComparator, true); } private int compareWithGroups(MyItem o1, MyItem o2) { if (o1 == o2) { return 0; } if (o1.isGroup()) { if (o2.isGroup()) { return (reversed ? -1 : 1) * o1.v1.compareTo(o2.v1); } else if (o2.group == o1) { return -1; } return (reversed ? -1 : 1) * o1.v1.compareTo(o2.group.v1); } if (o2.isGroup()) { if (o1.group == o2) { return 1; } return (reversed ? -1 : 1) * o1.group.v1.compareTo(o2.v1); } if (o1.group != o2.group) { return (reversed ? -1 : 1) * o1.group.v1.compareTo(o2.group.v1); } return (reversed ? -1 : 1) * itemComparator.compare(o1, o2); } } ColumnOneComparator.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import java.util.Comparator; import pkg$.*; public class ColumnOneComparator extends ColumnComparator { public ColumnOneComparator() { super(Comparator.comparing(o -> o.v1)); } } ColumnTwoComparator.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import java.util.Comparator; import pkg$.*; public class ColumnTwoComparator extends ColumnComparator { public ColumnTwoComparator() { super(Comparator.comparing(o -> o.v2)); } }