[转载]Add ComboTree field to a form - jQuery EasyUI

[转载]Add ComboTree field to a form – jQuery EasyUI.

ComboTree is a ComboBox with a drop-down tree. It can be used as a form field that can be posted to remote server.

In this tutorial we will create a register form that has name,address,city fields. The city field is a combotree field in which user can drop down a tree panel and select a specified city.

View Demo

Create Form

  1. <div id=“dlg” class=“easyui-dialog” style=“width:500px;height:250px;padding:10px 30px;”
  2. title=“Register” buttons=“#dlg-buttons”>
  3. <h2>Account Information</h2>
  4. <form id=“ff” method=“post”>
  5. <table>
  6. <tr>
  7. <td>Name:</td>
  8. <td><input type=“text” name=“name” style=“width:350px;”/></td>
  9. </tr>
  10. <tr>
  11. <td>Address:</td>
  12. <td><input type=“text” name=“address” style=“width:350px;”/></td>
  13. </tr>
  14. <tr>
  15. <td>City:</td>
  16. <td><select class=“easyui-combotree” url=“data/city_data.json” name=“city” style=“width:156px;”/></td>
  17. </tr>
  18. </table>
  19. </form>
  20. </div>
  21. <div id=“dlg-buttons”>
  22. <a href=“#” class=“easyui-linkbutton” iconCls=“icon-ok” onclick=“savereg()”>Submit</a>
  23. <a href=“#” class=“easyui-linkbutton” iconCls=“icon-cancel” onclick=JavaScript:$(‘#dlg’).dialog(‘close’)”>Cancel</a>
  24. </div>

See the code above, we set a url attribute for the combotree field named ‘city’, with which the field can retrieve tree data from remote server. Notice that the field has a class named ‘easyui-combotree’, so we don’t need to write any js code, the combotree field will be rendered automatically.

Download the EasyUI example:

easyui-form-demo.zip
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏