-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everyone, I dont know how can I select an Item of a combobox and use properties of a button when I use apply="org.zkoss.bind.BindComposer".
My application is: select items of a combobox's like: year, item, id and then, press a button and show a different data in a grid, depends on the combobox box selected.
I am gonna be very pleased if somebody can help me, cheers
Still not very clear... anyway here is a combo with dynamic data from your model:
<combobox model="@load(vm.cars)" selectedItem="@bind(vm.selectedCar)"
onSelect="@command('car-selected')" readonly="true" >
<template name="model" var="car">
<comboitem label="@load(car.type)" />
</template>
</combobox>
And here is a combo with static data:
<combobox selectedItem="@bind(vm.selectedComboItem)"
onSelect="@command('combo-item-selected')">
<comboitem label="Fiat" value="Fiat" />
<comboitem label="Audi" value="Audi" />
<comboitem label="Renault" value="Renault" />
</combobox>
Now, every time you select something in the combobox the selected value is stored automatically in the "selectedItem" attribute in your view model.
If you don't want to do anything upon selection then remove the onSelect attribute from the combobox's declaration.
Your button then may fire the command to do anything you want with the selected combo item:
<button onClick="@command('Buscar')" label="Buscar" />
@Command("Buscar")
public void onBuscar() {
if (selectedItem.equals ...)
.... do whatever you want ...
}
Hope that helps, Costas
It is not quite clear what you are trying to do. Maybe the "menupopup" attribute is what you are looking for. It opens a combobox to allow the user to select which columns will be visible:
<grid model="@load(vm.yourmodel)" >
<columns menupopup="auto">
<column label="ID" />
<column label="Name" />
<column label="Contact" />
</columns>
Now, if you want to do this manually then you may bind the "visible" attribute for each column to a property in your model. For example:
<grid model="@load(vm.yourmodel)" >
<columns>
<column label="ID" visible="@load(vm.isIdColumnVisible)" />
<column label="Name" visible="@load(vm.isNameColumnVisible)" />
<column label="Contact" visible="@load(vm.isContactColumnVisible)" />
</columns>
and use a bandbox to select the columns:
<bandbox id="bd" mold="rounded" autodrop="true">
<bandpopup>
<listbox multiple="true" checkmark="true">
<listhead>
<listheader label="Select columns" />
</listhead>
<listitem label="ID" />
<listitem label="Name" />
<listitem label="Contact" />
</listbox>
</bandpopup>
</bandbox>
/costas
<row>
<label value="Periodo" />
<combobox hflex="1" readonly="true"
id="combCurso">
<comboitem label="2" />
</combobox>
</row>
<row>
<div></div>
<button onClick="@command('Buscar')" label="Buscar" />
</row>
</rows>
</grid>
It exactly what I want, the problem is by the time I selected one item, it is going to execute the button, my application is going to have 3 combobox, after I selected all of them, I will press the button and make a query depends on the selected items.
With MyComposer.java in the div will be very easy, but I can't use because I neccesary will use databinding to change the data in a grid.
I am using data binding in the div like this:
Thank you for you answeer in advantage.
It is not necessary to use a composer, if all you need to do is to disable the button during the execution. The button has the "autodisable" property which solves these problems very efficiently:
<button id="ok" label="OK" autodisable="self" />
Check out this link.
/Costas
Asked: 2014-06-09 07:53:43 +0800
Seen: 37 times
Last updated: Jun 11 '14
infinite parent child hierarchy combobox
Combobox issue :Taking time to load
Zk Combobox onOpen Event issue
Combo box OnDouble Click Event and SelectedItem
Combobox model='xxx' whcih is not ListModel
Combobbox selectedItem issues. Unsupported child for Combobox: <Listitem null>
post zul and vm plz
chillworld ( 2014-06-09 08:55:41 +0800 )edit