May 09, 2021 jQuery EasyUI
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.
<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.