进行拖放操作后,我无法从列表框中获取新的有序模型列表。在视图中,我可以看到它是有序的,但是当我尝试获取新的项目列表时,它会返回原始列表。有什么方法可以按照屏幕上的顺序获取 listmodel 吗?
问问题
1279 次
2 回答
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);
}
}
于 2011-04-15T11:40:08.730 回答
0
In your case, you'd better to maintain the order in the model, rather than the component set. In other words, you should change the order in the model when drag and drop affected.
于 2011-04-14T02:41:42.670 回答