Cascader"
(refine Cascader) |
|||
Line 6: | Line 6: | ||
*Java API: [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zkmax/zul/Cascader.html Cascader] | *Java API: [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zkmax/zul/Cascader.html Cascader] | ||
*JavaScript API: [http://www.zkoss.org/javadoc/latest/jsdoc/zkmax/inp/Cascader.html Cascader] | *JavaScript API: [http://www.zkoss.org/javadoc/latest/jsdoc/zkmax/inp/Cascader.html Cascader] | ||
− | + | {{ZK EE}} | |
+ | [ since 9.0.0 ] | ||
= Employment/Purpose = | = Employment/Purpose = | ||
− | Cascader is a tree | + | A Cascader is a dropdown list in a tree structure, and it supports TreeModel. |
= Example = | = Example = | ||
+ | |||
+ | [[File:Cascader-example.png]] | ||
<source lang="xml" > | <source lang="xml" > | ||
− | + | <zscript><![CDATA[ | |
− | <zscript><![CDATA[ | ||
DefaultTreeModel tm = new DefaultTreeModel(new DefaultTreeNode("ROOT", | DefaultTreeModel tm = new DefaultTreeModel(new DefaultTreeNode("ROOT", | ||
Arrays.asList(new DefaultTreeNode[]{ | Arrays.asList(new DefaultTreeNode[]{ | ||
Line 29: | Line 31: | ||
= Properties = | = Properties = | ||
+ | |||
+ | == Disabled == | ||
+ | Sets whether it is disabled. A disabled component can't interact with users. | ||
+ | |||
+ | == ItemConverter == | ||
+ | The converter generates the label text shown in the cascader. By implementing your own <javadoc>org.zkoss.util.Converter</javadoc>, you can generate the label that represents the selected item. The default implementation is joining all the <code>toString()</code> result of items by slashes. | ||
+ | |||
+ | == ItemRenderer == | ||
+ | See also: [[ZK_Developer's_Reference/MVC/View/Renderer/Cascader_Renderer]] | ||
+ | |||
+ | The item renderer is used to render each item. | ||
+ | |||
+ | By implementing your own <javadoc>org.zkoss.zul.ItemRenderer</javadoc>, you can generate the HTML fragment for the data model. Normally you would like to use the default implementation and use <code><template name="model"></code> instead. | ||
== Model == | == Model == | ||
The tree model associated with this cascader. | The tree model associated with this cascader. | ||
+ | |||
+ | == Open == | ||
+ | Drops down or closes the list of items. | ||
== Placeholder == | == Placeholder == | ||
Line 37: | Line 55: | ||
(Default: empty) | (Default: empty) | ||
− | == | + | == selectedItem == |
− | + | Represents the selected item, or null if no item is selected. | |
− | + | A non-leaf item can't be selected in the cascader. For example, users can only select item C in an A - B - C structure. But items A and B can't be selected. | |
− | |||
− | |||
− | |||
− | |||
=Supported Events= | =Supported Events= | ||
Line 89: | Line 103: | ||
| 9.0.0 | | 9.0.0 | ||
| November, 2019 | | November, 2019 | ||
− | | [ | + | | [https://tracker.zkoss.org/browse/ZK-4392 ZK-4392]: Provide a cascader component |
|} | |} | ||
{{ZKComponentReferencePageFooter}} | {{ZKComponentReferencePageFooter}} |
Revision as of 04:36, 18 November 2019
Cascader
- Available for ZK:
[ since 9.0.0 ]
Employment/Purpose
A Cascader is a dropdown list in a tree structure, and it supports TreeModel.
Example
<zscript><![CDATA[
DefaultTreeModel tm = new DefaultTreeModel(new DefaultTreeNode("ROOT",
Arrays.asList(new DefaultTreeNode[]{
new DefaultTreeNode("David", Arrays.asList(new TreeNode[]{new DefaultTreeNode("David-1"),
new DefaultTreeNode("David-2")})),
new DefaultTreeNode("Thomas",new ArrayList()),
new DefaultTreeNode("Steven",new ArrayList())})));
]]></zscript>
<cascader width="300px" model="${tm}" />
Users can select in layers, and the selection path would be converted into text. (Default is joining by slashes, i.g. "A/B/C")
Properties
Disabled
Sets whether it is disabled. A disabled component can't interact with users.
ItemConverter
The converter generates the label text shown in the cascader. By implementing your own Converter, you can generate the label that represents the selected item. The default implementation is joining all the toString()
result of items by slashes.
ItemRenderer
See also: ZK_Developer's_Reference/MVC/View/Renderer/Cascader_Renderer
The item renderer is used to render each item.
By implementing your own ItemRenderer, you can generate the HTML fragment for the data model. Normally you would like to use the default implementation and use <template name="model">
instead.
Model
The tree model associated with this cascader.
Open
Drops down or closes the list of items.
Placeholder
When the selected item is empty, the placeholder text would be displayed. (Default: empty)
selectedItem
Represents the selected item, or null if no item is selected.
A non-leaf item can't be selected in the cascader. For example, users can only select item C in an A - B - C structure. But items A and B can't be selected.
Supported Events
Event: SelectEvent
Represents an event caused by user's the selection changed at the client. | |
Event: OpenEvent
Represents an event that indicates an open state that is changed at the client. |
- Inherited Supported Events: HtmlBasedComponent
Supported Children
* None
Use Cases
Version | Description | Example Location |
---|---|---|
Version History
Version | Date | Content |
---|---|---|
9.0.0 | November, 2019 | ZK-4392: Provide a cascader component |