easyUI 添加ComboTree 欄位到一個 form

來源:互聯網
上載者:User

@author YHC

ComboTree 是一個ComboBox 和一個下拉的tree,可以使用最為一個form欄位,可以提交給遠程伺服器.


在這個教程中我們將要建立一個註冊的form有一個name,address,city欄位,city 欄位是一個combotree 欄位,在裡面使用者可以下拉tree panel和選擇一個特定的city.

 


查看 Demo

 

建立 Form
[html]
<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>   

<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 欄位將自動渲染.
 

 

 作者:yhc13429826359
 


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.