0

Update model of listbox onchange Textbox

asked 2015-12-29 20:46:44 +0800

emax gravatar image emax
0 1

Hello to all, i'm a newbie in zk and i getting started with the MVVM tutorial: books.zkoss.org/wiki/ZKGettingStarted/GetZKUpandRunningwithMVVM To experiment, I put the event onchanging in the textbox, but when i put a text in a textbox the model of a listbox does not update. If i use onchange, the listbox is update only when unset focus (onblur). how do you?

 <hbox align="center">
    Cerca:
    <textbox value="@bind(vm.keyword)" onChanging="@command('search')" />
    <button onClick="@command('search')" label="Search" image="/img/search.png" />
</hbox>
<!-- CAR LIST -->
<listbox model="@bind(vm.carList)" selectedItem="@bind(vm.selectedCar)" height="160px" emptyMessage="No car found in the result">
    <listhead>
        <listheader label="model" />
        <listheader label="price" />
        <listheader label="make" />
    </listhead>
    <template name="model">
        <listitem>
            <listcell label="@bind(each.model)"></listcell>
            <listcell label="@bind(each.price)"></listcell>
            <listcell label="@bind(each.make)"></listcell>
        </listitem>
    </template>
</listbox>

ViewModel

@Command
@NotifyChange("carList") //ZK can reload the changed property for us after it invokes this method.
public void search(){
    carList = carService.search(keyword);
}

//get e set keyword public void setKeyword(String keyword) { this.keyword = keyword; } public String getKeyword() { return keyword; }

public List<Car> getCarList(){
    return carList;
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-30 06:17:09 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

If you want that the textbox updates with the onChanging event, please add

instant=true

In the textbox.

Greetz chill.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-12-29 20:46:44 +0800

Seen: 54 times

Last updated: Dec 30 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More