0

Update the datebox value and fire a onChange event (Client)

asked 2013-01-22 15:13:26 +0800

conversf gravatar image conversf
13 2

Why this work for texbox

<zk xmlns:w="client">
<textbox id="txt" value="test" onChange='alert("client updated:"+ event.getValue());' />
<button id="test" label="click me to change value and updateChange_" w:onClick="var t = zk.Widget.$('$txt');t.$n().value=('test2');t.updateChange_();" />
</zk>

and this don't work for datebox ?

<zk xmlns:w="client">
<datebox id="txt"  onChange='alert("client updated:"+ event.getValue());' />
<button id="test" label="click me to change value and updateChange_" w:onClick="var t = zk.Widget.$('$txt');t.$n().value=(new Date());t.updateChange_();" />
</zk>
delete flag offensive retag edit

Comments

Thank you neillee. I changed the code and the datebox (t.setValue(new Date());) now is valued, but unfortunately the onchange event is not yet fired. What's wrong?

conversf ( 2013-01-23 07:32:58 +0800 )edit

Thank you very much dennis. Now everything works.

conversf ( 2013-01-23 13:17:08 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-01-23 08:56:33 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

I will prefer to use widget api directly(method start/end with _ are not suggested to use since it is for internal only), use setValue(val) and fireOnChange(), please refer to setValue API here

<zk xmlns:w="client">
    <textbox id="txt" value="test"
        onChange='alert("client updated:"+ event.getValue());' />
    <button id="test" label="click me to change value and updateChange_"
        w:onClick="var t = zk.Widget.$('$txt');t.setValue('test2');t.fireOnChange()" />

    <datebox 
        id="dbx"  
        onChange='alert("client updated:"+ event.getValue());' />
    <button 
        id="test2" label="click me to change value and updateChange_" 
        w:onClick="var t = zk.Widget.$('$dbx');t.setValue(new Date());t.fireOnChange()" />
</zk>
link publish delete flag offensive edit
0

answered 2013-01-22 16:21:59 +0800

neillee gravatar image neillee flag of Taiwan
1692 1 5
https://plus.google.com/u...

updated 2013-01-22 16:28:07 +0800

Because datebox has a different DOM structure, you would need to change t.$n().value to t.$n('real').value to access the date string.

<zk xmlns:w="client">
    <datebox 
        id="dbx"  
        onChange='alert("client updated:"+ event.getValue());' />
    <button 
        id="test" label="click me to change value and updateChange_" 
        w:onClick="var t = zk.Widget.$('$dbx');t.$n('real').value=(new Date());t.updateChange_();" />
</zk>
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: 2013-01-22 15:13:26 +0800

Seen: 118 times

Last updated: Jan 23 '13

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