-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm trying to setup a MVVM listbox so that multiple items can be selected, like...
<listbox id="others" checkmark="true" multiple="true" selectedItems="@bind(vm.otherSelections)" model="@load(vm.othersModel)" vflex="true" mold="paging"> <auxhead> <auxheader label="Available" align="center" colspan="2"/> </auxhead> <listhead> <listheader label="Type" sort="auto" hflex="min" /> <listheader label="Name" sort="auto" /> </listhead> <template name="model" var="other"> <listitem> <listcell label="@load(other.typeTitle)" /> <listcell label="@load(other.planEntityTitle)" /> </listitem> </template> </listbox>
Could you provide a replay-able viewmodel,
And what is the type of othersModel? if it is a ListModel (not a simple collection), binder will not do extra handling on it, then according to the spec. of ListModel (and Selectable interface), you should setMultiple on it, not use multiple attribute on the component.
@itbean,
Here is a snippet, in your zul file if you have this
<window title="Order Management" border="normal" width="600px" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.zkoss.bind.examples.order.OrderVM')" validationMessages="@id('vmsgs')"> <vbox hflex="true"> <listbox model="@load(vm.orders)" selectedItem="@bind(vm.selected)" hflex="true" height="200px" checkmark="true">
Above if orders is of ListModelList type then you have to call setMultiple(true) on it to turn on the multiple selection. So in your VM
public ListModelList<Order> getOrders() { if (orders == null) { //init the list orders = new ListModelList<Order>(getService().list()); orders.setMultiple(true); } return orders; }
In above zul code, even if you set multiple="true" on the listbox it wouldn't turn on the multiple selection.
If your model is of generic collection type then ZK binder will automatically wrap it inot a BindingListModel and turn on multiple selection if you have set multiple="true" and checkmark="true" in your zul file.
Asked: 2012-08-05 13:54:17 +0800
Seen: 280 times
Last updated: Aug 06 '12