樹形下拉框是一個帶有下列樹形結構的下拉框。它能夠做爲一個表單字段進行使用,能夠提交給遠程服務器。javascript
在本教程中,咱們將要建立一個註冊表單,帶有name、address、city字段。city字段是一個樹形下拉框字段,在裏面用戶能夠下拉樹面板,並選擇一個特定的城市。html
jQuery EasyUI最新試用版下載請猛戳>>java
![建立樹形下拉框](http://static.javashuo.com/static/loading.gif)
點擊查看示例json
建立表單
1服務器 2post 3ui 4url 5spa 6code 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
< 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 > < tbody >< 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;" ></ select ></ td > </ tr > </ tbody ></ 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 > |
從上面的代碼能夠看到,咱們爲一個名爲 'city' 的樹形下拉框字段設置了一個url屬性,這個字段能夠從遠程服務器檢索樹形結構數據。請注意,這個字段有一個樣式名字叫 'easyui-combotree',因此咱們不須要寫任何的js代碼,樹形下拉框字段將自動渲染。
下載EasyUI示例:easyui-form-demo.zip
有興趣的朋友能夠點擊查看更多有關jQuery EasyUI的教程>>