Associate UI Components with a GroupsModel"

From Documentation
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
  
Similar to the previous section [[ZK_Developer's_Reference/Data_Binding/Associate_UI_Components_with_a_Collection | Associate UI Components with a Collection]],  you can also associate a <javadoc type="interface">org.zkoss.zul.GroupsModel</javadoc> with UI components, and Data Binding Manager will convert the GroupsModel into UI components accordingly.  
+
Similar to the previous section [[ZK_Developer's_Reference/Data_Binding/Associate_UI_Components_with_a_Collection | Associate UI Components with a Collection]],  you can also associate a <javadoc type="interface">org.zkoss.zul.GroupsModel</javadoc> with UI components, and the Data Binding Manager will convert the GroupsModel into UI components accordingly.  
  
 
# Prepare the data source of GroupsModel
 
# Prepare the data source of GroupsModel

Revision as of 02:07, 25 July 2011


DocumentationZK Developer's ReferenceData BindingAssociate UI Components with a GroupsModel
Associate UI Components with a GroupsModel


Similar to the previous section Associate UI Components with a Collection, you can also associate a GroupsModel with UI components, and the Data Binding Manager will convert the GroupsModel into UI components accordingly.

  1. Prepare the data source of GroupsModel
  2. Associate the GroupsModel with model attribute of those supported UI components, ex. Listbox and Grid.

In the following example, we demonstrate how to associate a GroupsModel with Listbox.

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>

<window width="500px">
	<zscript><![CDATA[ 
     //prepare the example group model
		Object[][] data = {
				{"cell 1-0", "cell 1-1"}, //group 1
				{"cell 2-0", "cell 2-1", "cell 2-2"}, //group 2
				{"cell 3-0", "cell 3-1", "cell 3-2", "cell 3-3"} //group 3
		};
		Object[] heads = { "group 1", "group 2", "group 3"};
		GroupsModel groupsmodel = new SimpleGroupsModel(data, heads);
		String selected = "cell 1-0";
     ]]>
 	</zscript>
	<listbox height="300px" model="@{groupsmodel}" selectedItem="@{selected}">
	</listbox>
	<label value="@{selected}"/>
</window>


Version History

Last Update : 2011/07/25


Version Date Content
     



Last Update : 2011/07/25

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