我将要在ZK使用列表项的重新排序,我们如何能做到这一点,当我们有定义ZUL文件内标签(列表项,listcell元素里面)。我不想用的ListItemRenderer 。 Here我发现的东西,但可能是他们没有更新的东西ZK在重新排序列表框
3
A
回答
3
列表框列重新排序
的folloing例如可以在zk fiddle找到了。
通过拖放
首先,我们延伸到弹出方式后来DND例子。
简单的观点:
<window apply="test.LboxViewCtrl">
<listbox id="lbox">
<listhead id="lHead">
<listheader draggable="head" droppable="head" label="Col A" />
<listheader draggable="head" droppable="head" label="Col B" />
<listheader draggable="head" droppable="head" label="Col C" />
</listhead>
<auxhead>
<auxheader colspan="3">
<button id="reorderBtn" label="Reorder" />
</auxheader>
</auxhead>
<listitem>
<listcell label="A1" />
<listcell label="B1" />
<listcell label="C1" />
</listitem>
<listitem>
<listcell label="A2" />
<listcell label="B2" />
<listcell label="C2" />
</listitem>
</listbox>
</window>
的评论解释控制器:
public class LboxViewCtrl extends SelectorComposer<Component> {
@Wire
private Listbox lbox;
@Wire
private Listhead lHead;
@Wire
private Panel menu;
@Wire
private Listbox box;
@Listen("onDrop = #lbox > #lHead > listheader")
public void onDroplHead(DropEvent ev) {
// get the dragged Listheader and the one it is dropped on.
Listheader dragged = (Listheader) ev.getDragged();
Listheader droppedOn = (Listheader) ev.getTarget();
// then get their indexes.
int from = lHead.getChildren().indexOf(dragged);
int to = lHead.getChildren().indexOf(droppedOn);
// swap the positions
lHead.insertBefore(dragged, droppedOn);
// swap related Listcell in all Listitem instances
for (Listitem item : lbox.getItems()) {
item.insertBefore(item.getChildren().get(from), item.getChildren().get(to));
}
}
}
现在我们可以DND列。
随着弹出
首先我们补充一点,打开我们的菜单的方法,如果我们点击列表框的按钮。
@Listen("onClick = #reorderBtn")
public void onEditorOpen(Event e) {
Window win = (Window) Executions.createComponents("/lbMenu.zul", this.getSelf(), null);
win.doModal();
}
当然,我们需要弹出一个观点:
<window id="menu" visible="false" closable="true" position="center" width="400px" height="150px" border="normal" title="Reorder" apply="test.MenuViewCtrl">
<listbox id="box">
<template name="model">
<listitem label="${each.label}" draggable="move" droppable="move" />
</template>
</listbox>
</window>
除了作为一个控制器:
@Wire
private Window menu;
@Wire
private Listbox box;
private Listhead lHead;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
// get the Listboxhead in which we like to change the the col order
lHead = (Listhead) menu.getParent().query("#lbox > #lHead");
// set the model for Listbox box in the pop up
box.setModel(new ListModelList<>(lHead.getChildren()));
}
@Listen("onDrop = listitem")
public void onDropInMenu(DropEvent ev) {
// get the draged and dropped again
Listitem dragged = (Listitem) ev.getDragged();
Listitem droppedOn = (Listitem) ev.getTarget();
// then get their indexes.
int from = box.getItems().indexOf(dragged);
int to = box.getItems().indexOf(droppedOn);
// swap the positions
lHead.insertBefore(lHead.getChildren().get(from), lHead.getChildren().get(to));
// swap related Listcell in all Listitem instances
for (Listitem item : lHead.getListbox().getItems()) {
item.insertBefore(item.getChildren().get(from), item.getChildren().get(to));
}
// swap the items in pop up Lisbox as well
box.insertBefore(dragged, droppedOn);
}
如果你想有向上/向下按钮,而不是DND ,只需看看这个zk demo.
列表框重新排序行
这是非常容易的,可以在ZK-Documentation和ZK Demosite快速找到。
在.zul,其中XXX
由data binding,el expression评估,以java.lang.Comparator
或者设置composer内只需添加
sortAscending="XXX" sortDescending="XXX"
到ZKS Listhead
组件。
0
我已经做了在ZUL本身重新排序,您可以检查Here
相关问题
- 1. ZK框架列表框排序不适用于动态标题?
- 2. ZK:组合框排序
- 3. 更新“简单”列表框ZK
- 4. 重新排序Python列表
- 5. jQuery重新排序表列
- 6. 重新排列的数字列表框
- 7. 在Mathematica中重新排序列表
- 8. 在python中重新排序列表
- 9. ZK列表框ONSELECT问题
- 10. 重新排序数据框中列
- 11. 重新排序列在MySQL
- 12. 在runtinme列重新排序
- 13. 重新排序列在SAS
- 14. 如何在列表框中流畅地重新排序集合?
- 15. 重新排列列表元素 - 序言
- 16. 重新排序列
- 17. SQL:重新排序列表顺序
- 18. 序言中的重新排序列表
- 19. 重新排列数据框?
- 20. 在ASP.net排序列表框
- 21. MVC jQuery重新排序列表没有在回发排序
- 22. 重新排列序列
- 23. 基于排序列和另一列值重新排序表
- 24. 重新排列Python列表
- 25. 重新排列表的列
- 26. 重排列表不排序
- 27. 角数据表不列重新排序
- 28. jquery表列拖放与重新排序
- 29. 如何重新排序PHAssetCollection列表
- 30. 重新排序列表视图下拉
我谈论Reorderding不排序 –
所以,请确定重新排序。对于我来说,重新排序就是诉诸于此,这就是你的例子中发生的事情,并且zk doc正在处理我的链接/我在示例中显示。 –
我已经发布了以下标题的问题:-ZK在列表框中重新排序不在ZK列表框中排序。在示例中,您可以看到重新排列图像。 –