⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 z35-listbox-0002.zul

📁 ZK是一个Ajax Java Web框架
💻 ZUL
字号:
<?xml version="1.0" encoding="UTF-8"?><!--Z35-grid-0102-2.zul{{IS_NOTE	Purpose:			Description:			History:		Tue May  6 09:29:59 TST 2008, Created by DennisChen}}IS_NOTECopyright (C) 2008 Potix Corporation. All Rights Reserved.{{IS_RIGHT}}IS_RIGHT--><window title="Live Data Demo" border="normal">	Grouping with Live Data - Different Model should has different grouping,	<html><![CDATA[  	<ol>	<li>Click 'group col0 asc' and 'group col0 dsc' to test group on column1 by name (Same alpha should in same group, forexample gorup A,group B),</li>	<li>you also need to check the group order in asc and dsc</li>	<li>Click 'group col1 asc' and 'group col1 dsc' to test group on column2 by number (Same value should in same group, forexample group 0,group 1)</li>	<li>you also need to check the group order in asc and dsc</li>	<li>in both group by col0 or col1, you should click the sort on the header, the group order will not change but order of item in each will change</li>	</ol>]]></html>	<zscript><![CDATA[//@DECLARATION	class MyComparator implements Comparator,GroupComparator {		boolean _asc;		boolean _gbyint;		public MyComparator(boolean asc,boolean gbyint) {			_asc = asc;			_gbyint = gbyint;		}		public int compare(Object o1, Object o2) {			//Row row1 = (Row)o1;			//Row row2 = (Row)o2;			String s1 = (String)o1;//row1.getChildren().get(0).getValue();			String s2 = (String)o2;//row2.getChildren().get(0).getValue();			int v = s1.compareTo(s2);			return _asc ? v: -v;		}				public int compareGroup(Object o1,Object o2){			String s1 = (String)o1;			String s2 = (String)o2;						if(_gbyint){				s1 = s1.substring(s1.length()-1);				s2 = s2.substring(s2.length()-1);			}else{				s1 = s1.substring(0,1);				s2 = s2.substring(0,1);			}			int v = s1.compareTo(s2);			return _asc ? v: -v;		}	}		class MyRowRenderer implements ListitemRenderer{		public void render(Listitem listitem, java.lang.Object data){			Listcell cell = new Listcell();			cell.setParent(listitem);			if(data instanceof String[]){				String str = ((String[])data)[0].toString();				new Label(str).setParent(cell);				if(Listitem.class.equals(listitem.getClass())){ 					cell = new Listcell();					cell.setParent(listitem);					new Label(str.charAt(str.length()-1)+"").setParent(cell);				}			}else if (data instanceof String){				String str = (data).toString();				new Label(str).setParent(cell);				if(Listitem.class.equals(listitem.getClass())) {					cell = new Listcell();					cell.setParent(listitem);					new Label(str.charAt(str.length()-1)+"").setParent(cell);				}			}else{				new Label("UNKNOW:"+data.toString()).setParent(cell);				if(Listitem.class.equals(listitem.getClass())){					cell = new Listcell();					cell.setParent(listitem);					new Label("UNKNOW:"+data.toString()).setParent(cell);				}			}		}	}	MyRowRenderer renderer = new MyRowRenderer();	]]></zscript>		<zscript><![CDATA[  	                  	   	ArrayList data = new ArrayList();		String[] datas ;		for(int j=0; j<=9; ++j) {			data.add("A option "+j);		}		for(int j=0; j<=8; ++j) {			data.add("B option "+j);		}		for(int j=0; j<=9; ++j) {			data.add("C option "+j);		}		for(int j=0; j<=8; ++j) {			data.add("D option "+j);		}for(int j=0; j<=9; ++j) {			data.add("E option "+j);		}		for(int j=0; j<=8; ++j) {			data.add("F option "+j);		}for(int j=0; j<=9; ++j) {			data.add("G option "+j);		}		for(int j=0; j<=8; ++j) {			data.add("H option "+j);		}		datas = data.toArray(new String[0]);		Comparator asc1 = new MyComparator(true,false);		Comparator dsc1 = new MyComparator(false,false);				Comparator asc2 = new MyComparator(true,true);		Comparator dsc2 = new MyComparator(false,true);				GroupsModel model1 = new ArrayGroupsModel(datas,asc1);		GroupsModel model2 = new org.zkoss.zkdemo.test2.group.Test1ArrayGroupsModel(datas,(Comparator)asc1);		GroupsModel lm = model2;	]]></zscript>		<div>	<button onClick="lm=model1;lb1.setModel(lm);" label="data head"/>	<button onClick="lm=model2;lb1.setModel(lm)" label="data ,head, foot"/>	<button onClick='lb1.setMold("paging");lb1.setPageSize(7)' label="set Paging"/>	<button onClick="lm.group(asc1,true,0)" label="group col0 asc"/>	<button onClick="lm.group(dsc1,false,0)" label="group col0 dsc"/>	<button onClick="lm.group(asc2,true,1)" label="group col1 asc"/>	<button onClick="lm.group(dsc2,false,1)" label="group col1 dsc"/>		<button onClick="lb1.invalidate();" label="invalidate"/>	 	</div> 	<listbox  width="500px" height="500px" model="${lm}" itemRenderer="${renderer}" id="lb1">		<listhead >			<listheader label="String" sortAscending="${asc1}" sortDescending="${dsc1}"/>			<listheader label="Number" sortAscending="${asc2}" sortDescending="${dsc2}"/>		</listhead>	</listbox>	</window>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -