easyUI 添加ComboTree 字段到一个 form
@author YHC
ComboTree 是一个ComboBox 和一个下拉的tree,可以使用最为一个form字段,可以提交给远程服务器.
在这个教程中我们将要创建一个注册的form有一个name,address,city字段,city 字段是一个combotree 字段,在里面用户可以下拉tree panel和选择一个特定的city.
查看 Demo
<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>看以上代码,我们为一个combotree 字段名字是'city'设置一个url属性,这个字段可以从远程服务器检索tree数据,注意这个字段有一个样式名字叫 'easyui-combotree',所以我们不需要写任何的js代码,combotree 字段将自动渲染.