制作拖放后我无法从列表框中获取新的有序模型列表放下操作。在视图中我可以看到它是有序的,但当我尝试获取新的项目列表时,它返回原始列表。有没有办法在屏幕上按顺序获取listmodel?
答案 0 :(得分:1)
我解决了它在模型列表中进行手动排序。我意识到当使用拖放时它只能直观地改变列表项目的顺序。这是我的工作代码
<listbox id="listBox_Action"
fixedLayout="true" width="300px"
model="@{mainCtrl.comboModelAction}"
selectedItem="@{mainCtrl.selectedAction}" mold="paging"
pageSize="25" forward="onSelect=onSelectedPanelChange()"
onSelect="bd.value=self.selectedItem.label;bd.close();">
<listhead>
<listheader
label="${c:l('SYSADM.SelectAction.combo.ActionName')}" />
</listhead>
<listitem
self="@{each=ACTION_LIST}">
<listcell
label="@{ACTION_LIST.action_func}"
value="@{ACTION_LIST.action_func}" />
</listitem>
</listbox>
这里是java类
public void onChangeList(ForwardEvent event) {
DropEvent dropEvent = (DropEvent) event.getOrigin();
// Listitem li = (Listitem)event.getTarget();
// Listbox lb =(Listbox)event.getOrigin().getTarget();
int indexOfdraggedListitem =0;
int indexOfdroppedListitem =0;
Listitem draggedListitem = (Listitem) dropEvent.getDragged();
if (dropEvent.getTarget() instanceof Listitem) {
droppedListitem = (Listitem) dropEvent.getTarget();
indexOfdraggedListitem = left.getIndexOfItem(draggedListitem);
indexOfdroppedListitem = left.getIndexOfItem(droppedListitem);
if (indexOfdraggedListitem > indexOfdroppedListitem) {
droppedListitem.getParent().insertBefore(draggedListitem, droppedListitem);
draggableListLeft.add(indexOfdroppedListitem, draggableListLeft.get(indexOfdraggedListitem));
// Collections.swap(draggableListLeft, indexOfdraggedListitem,
// indexOfdroppedListitem);
draggableListLeft.remove(indexOfdraggedListitem + 1);
// draggableListLeft.add(indexOfdroppedListitem + 1,
// temp_Fie_Dif_Request_Set);
} else {
droppedListitem.getParent().insertBefore(draggedListitem, droppedListitem);
draggableListLeft.add(indexOfdroppedListitem, draggableListLeft.get(indexOfdraggedListitem));
draggableListLeft.remove(indexOfdraggedListitem);
}
} else {
indexOfdraggedListitem = left.getIndexOfItem(draggedListitem);
left.appendChild(draggedListitem);
draggableListLeft.add(draggableListLeft.get(indexOfdraggedListitem));
draggableListLeft.remove(indexOfdraggedListitem);
}
}
答案 1 :(得分:0)
在您的情况下,您最好维护模型中的顺序,而不是组件集。换句话说,当拖放受影响时,您应该更改模型中的顺序。