-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Is there a way to create a new element through a combobox?
What I mean, is in the case that the autocomplete is activated, if the written string doesn't apply to any of the list and the user presses 'enter', get the string and use it to create a new item, or well, manipulate it in the view model?
I found a hack for this, even I think there should be a better solution. Anyway, I'll write it here, so I may get some feedback.
Given the combobox:
<combobox hflex="1" selectedItem="@save(vmApp.selectedModel)" model="@load(vmApp.model)" onChange="@command('createActivitySite', event=event)" autodrop="true" autocomplete="true" >
<template name="model" var="comboItem">
<comboitem hflex="1" label="@load(comboItem.getColumn('name').value)" />
</template>
</combobox>
And the events are based on the onChange event. In case there is an onChange and not selected item, I create a new one, as:
public void createActivitySite(@BindingParam("event") InputEvent e){
if (getSelectedModel()==null){
// if selected model is null, means that we have to create a new record
// Creation of the new record code
} else {
// that means that the on change is based on a selection of an existing item
// set the item with the selected model
}
BindUtils.postGlobalCommand(null, null, "addSite", args);
}
Asked: 2017-10-06 21:08:52 +0800
Seen: 15 times
Last updated: Nov 16 '17
combobox with password type zk 8.0.5
Combobox OnChange Event too slow
How to capture onScroll Event of Combobox
combobox does not scroll autocompleted text into view
I want to take different value from label(value) and pass to @bind object
Combobox sometimes clears the selected item
zk combobox filtering option is not working inside listbox .