Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

jQuery EasyUI Form - Create a Tree Pull-Down Box (ComboTree)


May 09, 2021 jQuery EasyUI


Table of contents


jQuery EasyUI Form - Create a tree pull-down box

This section describes how to create a tree pull-down box (ComboTree) for jQuery EasyUI.

A tree drop-down box is a ComboBox with the following tree structure. It can be used as a form field and can be submitted to a remote server.

In the following example, we're going to create a registration form with name, address, city fields. The city field is a tree-shaped pull-down box field in which the user can pull down the tree panel and select a specific city.

jQuery EasyUI Form - Create a Tree Pull-Down Box (ComboTree)

Create a form

	<div id="dlg" class="easyui-dialog" style="width:500px;height:250px;padding:10px 30px;" title="Register" buttons="#dlg-buttons">
		<h2>Account Information</h2>
		<form id="ff" method="post">
			<table>
				<tr>
					<td>Name:</td>
					<td><input type="text" name="name" style="width:350px;"/></td>
				</tr>
				<tr>
					<td>Address:</td>
					<td><input type="text" name="address" style="width:350px;"/></td>
				</tr>
				<tr>
					<td>City:</td>
					<td><select class="easyui-combotree" url="data/city_data.json" name="city" style="width:156px;"/></td>
				</tr>
			</table>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="savereg()">Submit</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>

As you can see from the code above, we set a url property for a tree pull-down box field called 'city', which retrieves Tree data from a remote server. Note that this field has a style name called 'easyui-combotree', so we don't need to write any js code, and the ComboTree field is rendered automatically.

Download the jQuery EasyUI instance

jeasyui-form-form2.zip