0

Assign value to textbox using zul expression value not bind to vm

asked 2019-12-31 10:52:29 +0800

sesong11 gravatar image sesong11
15 3

I have a textbox with bing value to vm.value

<textbox id="myTextbox" value="@bind(vm.value)"/>

on my combobox change I assign value to textbox as below

<combobox onChange="myTextbox.value = self.getSelectedItem().getValue()">
<comboitem label="hello" value="1" />
<comboitem label="hi" value="2" />
</combobox>

textbox value changed, but it doesn't change value on vm.

I use zk9

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2020-01-13 09:26:27 +0800

hawk gravatar image hawk
2550 1 5
http://hawkphoenix.blogsp... ZK Team

<combobox selectedItem="@bind(vm.value)" > gives you comboitem's value.

link publish delete flag offensive edit

Comments

This work for static Combobox, but it error when I change combobox to use listmodel. because value is integer and selectedItem is object, so I have to change type of value on View Model to object to make it work. Thank You!

sesong11 ( 2020-01-13 18:41:08 +0800 )edit
0

answered 2019-12-31 18:29:46 +0800

hawk gravatar image hawk
2550 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2019-12-31 18:40:58 +0800

jeanher gravatar image jeanher
1759 2 6
ZK Team

it should be <combobox value="@bind(vm.value)"/>

Don't mix MVC and MVVM pattern.

when you call component API setValue(), ZK doesn't know it so it can't notify the change on vm.value.

link publish delete flag offensive edit

Comments

<combobox value="@bind(vm.value)"/> does not bind selected value, it bind selected label. there are many questions related to this.

sesong11 ( 2020-01-03 11:34:20 +0800 )edit
0

answered 2020-01-08 17:49:12 +0800

hawk gravatar image hawk
2550 1 5
http://hawkphoenix.blogsp... ZK Team

if you use ZK 9 and depending on your requirements, we suggest other alternative components:

search and filter items

searchbox

select from a list

listbox select mold or selectbox.

link publish delete flag offensive edit

Comments

searchbox is available only ZK EE

sesong11 ( 2020-01-08 18:07:40 +0800 )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

RSS

Stats

Asked: 2019-12-31 10:52:29 +0800

Seen: 29 times

Last updated: Jan 13

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