easyUI 添加ComboTree 字段到一个 form

本文介绍了如何使用EasyUI库创建一个包含下拉树形控件的注册表单,该控件允许用户从远程服务器检索并选择特定的城市。通过设置表单元素的URL属性,实现数据的远程加载与交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

@author YHC

ComboTree 是一个ComboBox 和一个下拉的tree,可以使用最为一个form字段,可以提交给远程服务器.

在这个教程中我们将要创建一个注册的form有一个name,address,city字段,city 字段是一个combotree 字段,在里面用户可以下拉tree panel和选择一个特定的city.


查看 Demo

创建 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>  
看以上代码,我们为一个 combotree 字段名字是'city'设置一个url属性,这个字段可以从远程服务器检索tree数据,注意这个字段有一个样式名字叫'easyui-combotree',所以我们不需要写任何的js代码,combotree 字段将自动渲染.
下载 EasyUI示例代码:





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值