📄 model.zul
字号:
<window title="Live Data Demo" border="normal">
Grouping with Live Data - Different Model should has different grouping
<zscript><![CDATA[//@DECLARATION
class MyComparator implements Comparator {
boolean _asc;
public MyComparator(boolean asc) {
_asc = asc;
}
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;
}
}
class MyRenderer implements ListitemRenderer{
public void render(Listitem listitem, java.lang.Object data){
Listcell cell = new Listcell();
cell.setParent(listitem);
if(data instanceof String[]){
new Label(((String[])data)[0].toString()).setParent(cell);
}else if (data instanceof String){
new Label(data.toString()).setParent(cell);
}else{
new Label("UNKNOW:"+data.toString()).setParent(cell);
}
}
}
MyRenderer renderer = new MyRenderer();
]]></zscript>
<zscript><![CDATA[
String[][] datas = new String[4][];
datas[0] = new String[20];
datas[1] = new String[20];
datas[2] = new String[20];
datas[3] = new String[20];
for(int j=0; j<datas[0].length; ++j) {
datas[0][j] = j+"A option "+j;
}
for(int j=0; j<datas[1].length; ++j) {
datas[1][j] = j+"B option "+j;
}
for(int j=0; j<datas[2].length; ++j) {
datas[2][j] = j+"C option "+j;
}
for(int j=0; j<datas[3].length; ++j) {
datas[3][j] = j+"D option "+j;
}
GroupsModel model1 = new SimpleGroupsModel(datas);
GroupsModel model2 = new SimpleGroupsModel(datas,new String[]{"Group A","Group B","Group C","Group D"});
GroupsModel model3 = new SimpleGroupsModel(datas,new String[]{"Group A","Group B","Group C","Group D"},new String[]{"Foot A","Foot B","Foot C","Foot D"});
GroupsModel model4 = new SimpleGroupsModel(datas,new String[]{"Group A","Group B","Group C","Group D"},new String[]{"Foot A1",null,"Footer C1",null});
GroupsModel model5 = new SimpleGroupsModel(datas,new String[]{"Group A","Group B","Group C","Group D"},new String[]{null,"Foot B2",null,"Footer D2"});
Comparator asc = new MyComparator(true);
Comparator dsc = new MyComparator(false);
]]></zscript>
<hbox>
<button onClick="lb1.setModel(model1);" label="data only"/>
<button onClick="lb1.setModel(model2)" label="data ,head"/>
<button onClick="lb1.setModel(model3)" label="data,head,foot"/>
<button onClick="lb1.setModel(model4)" label="not all foot"/>
<button onClick="lb1.setModel(model5)" label="not all foot 2"/>
<button onClick='lb1.setMold("paging");lb1.setPageSize(7)' label="set Paging"/>
<button onClick="lb1.invalidate();" label="invalidate"/>
</hbox>
<listbox id="lb1" width="500px" height="500px" model="${model2}" itemRenderer="${renderer}" >
<listhead>
<listheader label="Load on Demend" sortAscending="${asc}" sortDescending="${dsc}"/>
</listhead>
</listbox>
</window>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -