Processing...

Suggested case list:

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

identify firefox or not in server side

1TonyQ198.203.175.1751nv2qreDec 10, 2011 4:25:04 AMlink

ZK addThis integration

1TonyQ198.203.175.1751apl96jNov 5, 2011 4:12:50 AMlink

Latest 10 Fiddles :

Vflex TableLayout

1guest186.10.247.2221f5en1hJan 24, 2020 9:01:19 PMlink

how to refresh a listbox page after closing the popup window

380guest197.249.39.1825nk0uiJan 24, 2020 4:53:24 PMlink

how to refresh a listbox page after closing the popup window

379guest197.249.39.1825nk0uiJan 24, 2020 4:52:18 PMlink

Apex

4guest208.87.234.180tf74icJan 24, 2020 1:58:31 PMlink

Apex

3guest208.87.234.180tf74icJan 24, 2020 1:58:24 PMlink

Remove whitespaces between elements

3guest212.186.131.2041simhhsJan 24, 2020 9:01:28 AMlink

Weird display

2guest212.186.131.2041simhhsJan 24, 2020 8:40:20 AMlink

Weird display

1guest212.186.131.2041simhhsJan 24, 2020 8:18:23 AMlink

Listbox Pagination

168guest182.78.143.2542rk65rnJan 24, 2020 7:39:05 AMlink

Another new ZK fiddle

11guest36.89.153.1501q1li3qJan 24, 2020 4:00:11 AMlink

Another new ZK fiddle

12guest220.134.32.2421pq0c6pDec 6, 2019 8:40:53 AMlink

resources

index.zulzul<?page title="ZK Big Listbox Demo for 1 Trillion Data"?> <zk> <window title="Big Listbox Demo for 1 Trillion Data" border="normal" apply="pkg$.B65_ZK_2172_Composer" width="100%" height="100%"> <div> <button label="Set Frozen" onClick="myComp.setFrozenCols(3);" /> </div> <vlayout width="100%" vflex="1"> <biglistbox id="myComp" hflex="1" vflex="1"></biglistbox> </vlayout> </window> </zk> B65_ZK_2172_Composer.javajavaimport java.util.Arrays; import java.util.Comparator; import java.util.List; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.MouseEvent; import org.zkoss.zk.ui.event.SelectEvent; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Listen; import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zkmax.zul.Biglistbox; import org.zkoss.zkmax.zul.MatrixComparatorProvider; import org.zkoss.zkmax.zul.MatrixRenderer; import org.zkoss.zul.Div; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window; import java.util.AbstractList; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import org.zkoss.lang.Objects; import org.zkoss.zkmax.zul.MatrixModel; import org.zkoss.zul.AbstractListModel; import org.zkoss.zul.event.ListDataEvent; import org.zkoss.zul.ext.Sortable; /** * A demo of Big listbox to handle 1 trillion data. * @author jumperchen */ public class B65_ZK_2172_Composer extends SelectorComposer<Window> { @Wire private Biglistbox myComp; @Wire private Div tip; @Wire private Textbox content; // images marks private String[] images = { "aim", "amazon", "android", "apple", "bebo", "bing", "blogger", "delicious", "digg", "facebook", "flickr", "friendfeed", "google", "linkedin", "netvibes", "newsvine", "reggit", "rss", "sharethis", "stumbleupon", "technorati", "twitter", "utorrent", "vimeo", "vkontakte", "wikipedia", "windows", "yahoo" }; public void doAfterCompose(Window comp) throws Exception { super.doAfterCompose(comp); // specify a trillion faker model myComp.setModel(new FakerMatrixModel(10 * 10, 10 * 10)); myComp.setColWidth("130px"); myComp.setMatrixRenderer(new MatrixRenderer<List<String>>() { public String renderCell(Component owner, List<String> data, int rowIndex, int colIndex) throws Exception { String d = data.get(colIndex); d = d.replace("ZK", "<span class='red' title='ZK'>ZK</span>") .replace("Hello", "<span class='blue' title='Hello'>Hello</span>"); return "<div class='images_" + (colIndex%28) + "' title='x=" + colIndex + ",y=" + rowIndex + "'>" + d + "</div>"; } public String renderHeader(Component owner, List<String> data, int rowIndex, int colIndex) throws Exception { return "<div class='images_" + (colIndex % 28) + "' title='" + images[colIndex % 28] + "'>" + data.get(colIndex) + "</div>"; } }); myComp.setSortAscending(new MyMatrixComparatorProvider<List<String>>(true)); myComp.setSortDescending(new MyMatrixComparatorProvider<List<String>>(false)); } @Listen("onClick=#myComp; onSort=#myComp") public void onClick() { tip.setVisible(true); // reset first, if the tip is shown at client only. tip.setVisible(false); } @SuppressWarnings("unchecked") @Listen("onCellClick=#myComp") public void onCellClick(MouseEvent evt) { Integer[] axis = (Integer[]) evt.getData(); // shift some pixels to make it look better tip.setStyle("left: " + (evt.getPageX() - 30) + "px; top:" + (evt.getPageY() + 20) + "px"); tip.setVisible(true); FakerMatrixModel fmm = (FakerMatrixModel) myComp.getModel(); content.setValue(String.valueOf(fmm.getCellAt( fmm.getElementAt(axis[1]), axis[0]))); content.setAttribute("axis", axis); // store the change for update Clients.evalJavaScript("doPosition()"); // resync the tooltip position } @Listen("onClick=#update; onOK=#content") public void onClick$update() { Integer[] axis = (Integer[]) content.getAttribute("axis"); FakerMatrixModel fmm = (FakerMatrixModel) myComp.getModel(); fmm.update(axis, content.getValue()); tip.setVisible(false); myComp.focus(); // pass focus to the big listbox } @Listen("onSelect=#myComp") public void onSelect(SelectEvent evt) { System.out.println("You listen onSelect: " + Arrays.asList(((Integer[]) evt.getData()))); } // Matrix comparator provider private class MyMatrixComparatorProvider<T> implements MatrixComparatorProvider<List<String>> { private int _x = -1; private boolean _acs; private MyComparator _cmpr; public MyMatrixComparatorProvider(boolean asc) { _acs = asc; _cmpr = new MyComparator(this); } public Comparator<List<String>> getColumnComparator(int columnIndex) { this._x = columnIndex; return _cmpr; } // a real String comparator private class MyComparator implements Comparator<List<String>> { private MyMatrixComparatorProvider _mmc; public MyComparator(MyMatrixComparatorProvider mmc) { _mmc = mmc; } public int compare(List<String> o1, List<String> o2) { return o1.get(_mmc._x).compareTo(o2.get(_mmc._x)) * (_acs ? 1 : -1); } } } } class FakerMatrixModel<Head extends List, Row extends List, Cell, Header> extends AbstractListModel<Row> implements MatrixModel<Row, Head, Cell, Header>, Sortable { // a rendering function private interface Fun<T> { public T apply(int index); } // A faker of key list implementation that contains a key to speed up the performance. // Because Java Collection framework didn't handle it well for huge data, it will // go through whole the list entries to receive the value for those methods, // hashCode(), equals(), and toString() private class FakerKeyList<T> extends AbstractList<T> { final int _size; Map<String, T> _updateCache = new HashMap<String,T> (); final Fun<?> _fn; final String _key; public FakerKeyList(int size, int key, Fun<?> fn) { _size = size; _key = key + "_" + size; _fn = fn; } public int size() { return _size; } public boolean isEmpty() { return _size == 0; } public T get(int index) { // if changed, returns the changed value Object val = _updateCache.get(String.valueOf(index)); if (val != null) return (T) val; return (T) _fn.apply(index); } public T set(int index, T element) { _updateCache.put(String.valueOf(index), element); return element; } public int hashCode() { return _key.hashCode(); } public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof FakerKeyList) { return _key.equals(((FakerKeyList)(obj))._key); } return false; } public String toString() { return _key; } } private int _colSize; private int _rowSize; private Map<String, List<String>> _rowCache; private List<List<String>> _headerData; private Comparator<Cell> _sorting; private boolean _sortDir = true; @SuppressWarnings("unchecked") public void sort(Comparator cmpr, boolean ascending) { _sorting = cmpr; _sortDir = ascending; fireEvent(ListDataEvent.STRUCTURE_CHANGED, -1, -1); } public String getSortDirection(Comparator cmpr) { if (Objects.equals(_sorting, cmpr)) return _sortDir ? "ascending" : "descending"; return "natural"; } public FakerMatrixModel(int colSize, int rowSize) { _colSize = colSize; _rowSize = rowSize; _rowCache = new HashMap<String, List<String>>(); _headerData = new ArrayList<List<String>>(); _headerData.add(new FakerKeyList<String>(colSize, 0, new Fun() { public Object apply(int index) { return "Header x = " + index; } })); } public FakerMatrixModel(int colSize, int rowSize, int headSize) { _colSize = colSize; _rowSize = rowSize; _rowCache = new HashMap<String, List<String>>(); _headerData = new ArrayList<List<String>>(); for (int i = 0; i < headSize; i++) { final int rowIndex = i; _headerData.add(new FakerKeyList<String>(colSize, 0, new Fun() { public Object apply(int index) { return "Header x = " + index + ", y = " + rowIndex; } })); } } public void update(Integer[] axis, String value) { List<String> list = _rowCache.get(String.valueOf(axis[1])); list.set(axis[0], value); this.fireEvent(ListDataEvent.CONTENTS_CHANGED, axis[0], axis[1]); } public void setSize(int colSize, int rowSize) { _colSize = colSize; _rowSize = rowSize; this.fireEvent(ListDataEvent.STRUCTURE_CHANGED, -1, -1); } @SuppressWarnings("unchecked") public Row getElementAt(int index) { final int rowIndex = _sortDir ? index : getSize() - index - 1; // handle the sorting final String key = String.valueOf(rowIndex); List<String> value = _rowCache.get(key); if (value == null) { value = new FakerKeyList<String>(_colSize, rowIndex, new Fun() { public Object apply(int index) { return "y = " + rowIndex; }}); _rowCache.put(key, value); } return (Row) value; } public int getSize() { return _rowSize; } public int getColumnSize() { return _colSize; } public int getHeadSize() { return _headerData.size(); } @SuppressWarnings("unchecked") public Head getHeadAt(int rowIndex) { return (Head) _headerData.get(rowIndex); } @SuppressWarnings("unchecked") public Cell getCellAt(Row rowData, int columnIndex) { return (Cell) rowData.get(columnIndex); } @SuppressWarnings("unchecked") public Header getHeaderAt(Head headData, int columnIndex) { return (Header) headData.get(columnIndex); } }