0

Manually lock doublespinner buttons

asked 2021-04-07 00:59:52 +0800

Jtt gravatar image Jtt
105 3

I probably am using very wrong words to ask this, sorry!

I was using the "min 0.0" constraint in a doublespinner. I liked that because it prevented the use to user the spinner to get below 0. This field, however is not read-only and users will need to type in the quantities they need. Because of this, adding the "no negative" constraint was a given, but it doesn't match the desired output. By this I mean that the response to the user is not the one we intended (We don't need to alert the user about this. This kind of situations will more likely be uncommon typos, so throwing errors is a bit overkill).

So instead I use a validator but I'd like to keep the behaviour of the constraint locking the spinner when it reaches 0. Is there a manual way to add only this? I don't really need the notification. Thsnk you!

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-04-07 13:02:42 +0800

cor3000 gravatar image cor3000
5868 2 7
ZK Team

I hope I understood your requirements correctly and implemented a simple example showing on way to override a client side function to limit the typed values to 0 before triggering validation.

https://zkfiddle.org/sample/2aq905g/1-doublespinner-lock-to-zero

If this is not 100% what you need please clarify, often I can adjust the code as needed.

link publish delete flag offensive edit

Comments

Yes! This is exactly what I was looking for! I see that it's using the JS API, just I don't fully get how $updateChange_ works. With updateChange_ alone, the returned input value is double and with adding $ to it, it returns an integer. How does this works?

Jtt ( 2021-04-10 22:35:29 +0800 )edit

the function name prefixed with $ is just the old method before overriding, it has nothing to do with int vs double, it's just a convention so you can call the original method after applying your additional logic

cor3000 ( 2021-04-11 10:12:10 +0800 )edit
1

here the internal override api used by ZK explaining the $ prefix https://www.zkoss.org/javadoc/latest/jsdoc/global/zk.html#override-java.lang.Object-global.String-java.lang.Object-

cor3000 ( 2021-04-11 10:12:47 +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
1 follower

RSS

Stats

Asked: 2021-04-07 00:59:52 +0800

Seen: 6 times

Last updated: Apr 07

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