Spinner"

From Documentation
 
(16 intermediate revisions by 6 users not shown)
Line 3: Line 3:
 
= Spinner =
 
= Spinner =
  
*Demonstration: [http://www.zkoss.org/zkdemo/userguide/#f2 Spinner]
+
*Demonstration: [http://www.zkoss.org/zkdemo/input/form_sample Spinner]
 
*Java API: <javadoc>org.zkoss.zul.Spinner</javadoc>
 
*Java API: <javadoc>org.zkoss.zul.Spinner</javadoc>
 
*JavaScript API: <javadoc directory="jsdoc">zul.inp.Spinner</javadoc>
 
*JavaScript API: <javadoc directory="jsdoc">zul.inp.Spinner</javadoc>
 +
*Style Guide: [[ZK_Style_Guide/XUL_Component_Specification/Spinner | Spinner]]
  
 
= Employment/Purpose =
 
= Employment/Purpose =
Line 12: Line 13:
 
= Example =
 
= Example =
  
 
+
[[Image:ZKComRef_Spinner.png]]
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 31: Line 32:
 
<source lang="xml">
 
<source lang="xml">
 
<zk xmlns:c="client">
 
<zk xmlns:c="client">
   <spinner inplace="true" value="240" width="25px" c:onFocus='this.setWidth("60px")' c:onBlur='this.setWidth("25px")' />
+
   <spinner inplace="true" value="240" width="30px" c:onFocus='this.setWidth("60px")' c:onBlur='this.setWidth("30px")' />
 
</zk>
 
</zk>
 
</source>
 
</source>
  
=Supported events=
+
=Properties=
 +
 
 +
== Format ==
 +
You are able to format the field by providing specifying the attribute with a formatting string. The default value is <code>null</code>.
 +
 
 +
<source lang="xml" >
 +
<spinner format="#,##0.##"/>
 +
</source>
 +
 
 +
{{versionSince| 8.5.2}}
 +
You can provide a locale to format the number by specifying the String starts with "locale:"
 +
 
 +
<source lang="xml" >
 +
<spinner format="locale:zh-TW"/>
 +
</source>
 +
 
 +
== Constraint ==
 +
You could specify what value to accept for input controls by use of the <code>constraint </code>property.
 +
It could be a combination of <code>no empty</code> and the minimum and maximum to spinner.
 +
 
 +
To specify two or more constraints, use comma to separate them as follows.
 +
 
 +
<source lang="xml" >
 +
<spinner constraint="no empty,min -2 max 6"/>
 +
</source>
 +
 
 +
If you prefer to display different message to the default one, you can append the error message to the constraint with a colon.
  
{| border="1" | width="100%"
+
<source lang="xml" >
 +
<spinner constraint="no empty,min -2 max 6: between -2 to 6"/>
 +
</source>
 +
 
 +
Notes:
 +
* The error message, if specified, must be the last element and start with colon.
 +
* To support multiple languages, you could use the 「l」 function as depicted in the '''Internationalization''' chapter.
 +
 
 +
<source lang="xml" >
 +
<spinner constraint="no empty,min -2 max 6: ${c:l('err.msg.spinner')}"/>
 +
</source>
 +
 
 +
=Inherited Functions=
 +
 
 +
Please refer to [[ZK_Component_Reference/Base_Components/NumberInputElement| NumberInputElement]] for inherited functions.
 +
 
 +
=Supported Events=
 +
 
 +
{| class='wikitable' | width="100%"
 
! <center>Name</center>
 
! <center>Name</center>
 
! <center>Event Type</center>
 
! <center>Event Type</center>
Line 43: Line 88:
 
| None
 
| None
 
| None  
 
| None  
 +
|}
 +
*Inherited Supported Events: [[ZK_Component_Reference/Base_Components/NumberInputElement#Supported_Events | NumberInputElement]]
 +
 +
=Supported Molds=
 +
Available molds of a component are defined in lang.xml embedded in zul.jar.
 +
{| class='wikitable' | width="100%"
 +
! <center>Name</center>
 +
! <center>Snapshot</center>
 +
|-
 +
| <center>default</center>
 +
|[[Image:spinner_mold_default.png ]]
 +
|-
 +
| <center>rounded</center>
 +
|[[Image:spinner_mold_rounded.png ]]
 +
{{versionSince| 5.0.0}}
 
|}
 
|}
  
 
=Supported Children=
 
=Supported Children=
  
  *ALL
+
  *None
  
=Use cases=
+
=Use Cases=
  
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Description !! Example Location
 
! Version !! Description !! Example Location
 
|-
 
|-
Line 60: Line 120:
  
 
=Version History=
 
=Version History=
 
+
{{LastUpdated}}
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Latest revision as of 01:45, 29 May 2023

Spinner

Employment/Purpose

An edit box for holding a constrained integer.

Example

ZKComRef Spinner.png

 <window title="Spinner" border="normal" width="150px">
     <spinner />
 </window>

In-place Editing

Fixed Width

<spinner width="100px" inplace="true" value="30" />

Dynamic Width

Because inplace editing function in ZK is pure client side action, so we can use client api to modify the width (server side do not need to know)

ZK Component Reference-Input-Spinner-inplace.jpg

<zk xmlns:c="client">
  <spinner inplace="true" value="240" width="30px" c:onFocus='this.setWidth("60px")' c:onBlur='this.setWidth("30px")' />
</zk>

Properties

Format

You are able to format the field by providing specifying the attribute with a formatting string. The default value is null.

<spinner format="#,##0.##"/>

Since 8.5.2 You can provide a locale to format the number by specifying the String starts with "locale:"

<spinner format="locale:zh-TW"/>

Constraint

You could specify what value to accept for input controls by use of the constraint property. It could be a combination of no empty and the minimum and maximum to spinner.

To specify two or more constraints, use comma to separate them as follows.

<spinner constraint="no empty,min -2 max 6"/>

If you prefer to display different message to the default one, you can append the error message to the constraint with a colon.

<spinner constraint="no empty,min -2 max 6: between -2 to 6"/>

Notes:

  • The error message, if specified, must be the last element and start with colon.
  • To support multiple languages, you could use the 「l」 function as depicted in the Internationalization chapter.
<spinner constraint="no empty,min -2 max 6: ${c:l('err.msg.spinner')}"/>

Inherited Functions

Please refer to NumberInputElement for inherited functions.

Supported Events

Name
Event Type
None None

Supported Molds

Available molds of a component are defined in lang.xml embedded in zul.jar.

Name
Snapshot
default
Spinner mold default.png
rounded
Spinner mold rounded.png

Since 5.0.0

Supported Children

*None

Use Cases

Version Description Example Location
     

Version History

Last Update : 2023/05/29


Version Date Content
     



Last Update : 2023/05/29

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.