jQuery EasyUI Form - Creating Tree ComboBox
The Tree ComboBox (ComboTree) is a ComboBox with a tree structure in it. It can be used as a form field and submitted to a remote server.
In this tutorial, we will create a registration form with fields for name, address, and city. The city field is a Tree ComboBox field where users can expand the tree panel and select a specific city.
Creating the 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>
From the code above, we can see that we have set a url attribute for the Tree ComboBox field named 'city', which retrieves tree data from a remote server. Note that this field has a class name 'easyui-combotree', so we don't need to write any JavaScript code; the Tree ComboBox field will be rendered automatically.