使用了 Listbox 控件, setModel 方式绑定数据, 但是发现, 在滚动中出现了数据加载的延迟现象。 这个效果可能不能接受。
<listbox id="searchResult" height="500px" fixedLayout="true" >
<listhead sizable="false" height="20px">
<listheader label="选择" align="left" width="45px"/>
<listheader label="工号" align="left"/>
<listheader label="姓名" align="left"/>
<listheader label="单位" align="left"/>
<listheader label="机型" align="left"/>
<listheader label="教员标准" align="left"/>
<listheader label="检查员标准" align="left" width="85px"/>
</listhead><!--
<listitem height="20px" forEachBegin="1" self="@{each='pilotBasicInfor'}" value="@{pilotBasicInfor}">
<listcell ><radio value="@{pilotBasicInfor.basicInfoId}" radiogroup="choosePilotInfor" onCheck="controller.pilotInforOnSelect(self)" ></radio></listcell>
<listcell label="@{pilotBasicInfor.clerkCode}" />
<listcell>
<a label="@{pilotBasicInfor.pilotName}"/>
</listcell>
<listcell label="@{pilotBasicInfor.unitName}" />
<listcell
label="@{pilotBasicInfor.acTypeName}" />
<listcell label="@{pilotBasicInfor.teacherTypeName}" />
<listcell label="@{pilotBasicInfor.inspectorTypeName}" />
</listitem> -->
</listbox>
注释了上面的绑定代码,
采用了在 Java 中创建组建添加到 ListBox 中的方式 , 解决了这个延迟的问题 。 代码:
OrderablePagination orderablePagination = new OrderablePagination(0, 0, 0);
orderablePagination.setTotalCount(0);
listPiv = (List<PeopleDto>) this.executeQuery(orderablePagination);
Listbox listResult = (Listbox) self.getFellowIfAny("searchResult");
listResult.getItems().clear();
listResult.setCheckmark(true);
listResult.setMultiple(false);
for(PeopleDto p : listPiv){
System.out.println("-------------"+p.getPilotName());
// if(i == 10)
// break;
final Listitem li = new Listitem();
li.setParent(listResult);
li.setValue(p.getBasicInfoId().toString());
li.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event arg0) throws Exception {
// TODO Auto-generated method stub
checkedBasicInforID = new Long(li.getValue().toString());
}
});
Listcell cell = new Listcell();
li.appendChild(cell);
li.appendChild(new Listcell(p.getClerkCode()));
li.appendChild(new Listcell(p.getPilotName()));
li.appendChild(new Listcell(p.getUnitName()));
li.appendChild(new Listcell(p.getAcTypeName()));
li.appendChild(new Listcell(p.getTeacherTypeName()));
li.appendChild(new Listcell(p.getInspectorTypeName()));
// i++;
}
但是, 每次查询的时候, 旧的数据不能清空, 需要手动调用方法:
注意此处调用的代码 :
listResult.getItems().clear();
ListBox 中的 ListHead 不会被清除, 但是加载的 ListItem 会被清空。 。
然后加载数据 。
listResult.setCheckmark(true);
listResult.setMultiple(false);
设置成为 单选列表。