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 :

Scrollable Panel

29guest188.114.102.141qr4n3lAug 3, 2020 10:36:27 AMlink

Chart custom export with toggle

2guest172.69.35.131t3d0qmAug 3, 2020 8:56:32 AMlink

Chart custom export with toggle

1guest172.69.35.131t3d0qmAug 3, 2020 8:56:10 AMlink

cabinete creation modified

8guest172.68.186.522qnjc7jAug 2, 2020 5:10:50 PMlink

Grid with rowspan

47guest162.158.31.1543f1bldeJul 31, 2020 9:43:13 AMlink

Grid with rowspan

46guest162.158.31.1543f1bldeJul 31, 2020 9:43:00 AMlink

font awsome in borderlayout

454patman162.158.126.1063hsg6tpJul 30, 2020 6:21:34 PMlink

font awsome in borderlayout

354patman162.158.126.1063hsg6tpJul 30, 2020 6:18:55 PMlink

font awsome in borderlayout

254patman162.158.126.1063hsg6tpJul 30, 2020 6:13:57 PMlink

font awsome in borderlayout

154patman162.158.126.1063hsg6tpJul 30, 2020 6:12:44 PMlink

biglistbox override

10guest220.134.32.2421pq0c6pDec 6, 2019 8:33:13 AMlink

resources

index.zulzul<?page title="ZK Big Listbox Demo for 1 Trillion Data"?> <zk> <script><![CDATA[ zk.afterLoad("zul", function () { var _xWScroll = {}; zk.override(zul.WScroll.prototype, _xWScroll, { syncSize: function (opts) { if (opts) { this.opts = zk.copy(this.opts, opts); } this.edrag.style.display = ''; if (this._isVer) { var opts = this.opts, top = opts.startPosition, start = opts.startStep, view = opts.viewport, end = opts.endStep, vsize = opts.viewportSize, rest = end - view, edragHeight = this.edrag.offsetHeight - this._gap; if (rest <= 0) { this.eend.style.display = this.edrag.style.display = 'none'; if (typeof this.opts.onScrollY == 'function') this.opts.onScrollY.call(this.widget, opts.offset); return; } vsize -= edragHeight; if (vsize > rest && false) { this.epos.style.height = edragHeight + 'px'; this._scale = 1; var es = this.eend.style; es.display = ''; es.top = top + edragHeight + rest + 'px'; } else { var rate = vsize / rest, height = 5; this.epos.style.height = height + 'px'; this._scale = rate; this.eend.style.display = 'none'; if (vsize < 10) this.edrag.style.display = 'none'; } var top1 = top + (this._scale * start), top2 = top + vsize; if (top1 > top2) top1 = top2; this.epos.style.top = this.edrag.style.top = top1 + 'px'; } else { var opts = this.opts, left = opts.startPosition, start = opts.startStep, view = opts.viewport, end = opts.endStep, vsize = opts.viewportSize, rest = end - view, edragWidth = this.edrag.offsetWidth - this._gap; if (rest <= 0) { this.eend.style.display = this.edrag.style.display = 'none'; if (typeof this.opts.onScrollX == 'function') this.opts.onScrollX.call(this.widget, opts.offset); return; } vsize -= edragWidth; if (vsize > rest && false) { this.epos.style.width = edragWidth + 'px'; this._scale = 1; var es = this.eend.style; es.display = ''; es.left = left + edragWidth + rest + 'px'; } else { var rate = vsize / rest, width = 5; this.epos.style.width = width + 'px'; this._scale = rate; this.eend.style.display = 'none'; if (vsize < 10) this.edrag.style.display = 'none'; } var left1 = left + (this._scale * start), left2 = left + vsize; if (left1 > left2) left1 = left2; this.epos.style.left = this.edrag.style.left = left1 + 'px'; } } }); }); ]]></script> <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); } }