easyui combobox两种联动方法与导致ie6崩溃问题


$(function(){
var stEventType = $('#stEventType').combobox({
url:'sub_template/code_json.jsp?type=EVENT_TYPE',
editable:false,
valueField:'tid',
textField:'text',
required:true,
onSelect:function(record){
stEventName.combobox({
url:'sub_template/code_json.jsp?type='+record.tid,
editable:false,
valueField:'tid',
textField:'text',
required:true
}).combobox('clear');
}

});
var sub_value = $('#stEventType').combobox('getValue');
if(sub_value==''){
sub_value='EVENT_TYPE_1';
}
var stEventName = $('#stEventName').combobox({
url:'sub_template/code_json.jsp?type='+sub_value,
editable:false,
valueField:'tid',
textField:'text',
required:true
});
$('#stDiscoverUnit').combobox({
editable:false,
url:'sub_template/unit_json.jsp?streetId=<%=(String)session.getAttribute("streetId")%>&typestr=1~2~-1',
valueField:'text',
required:true,
textField:'text'
});
$("#type_div").show();
$("#name_div").show();
});



<div id="type_div" style="display:none">
<input id="stEventType" type="text" style="width:155px" value=""/>
</div>
</td>
<td align="center" valign="middle" class="table_title" nowrap="nowrap" >
<font color="red">*</font>事件名称</td>
<td class="table_content">
<div id="name_div" style="display:none">
<input id="stEventName" type="text" style="width:155px" value=""/>
</div>


用于combobox的联动 div一般情况下是可以不需要的 这里加上主要是因为数据回显的时候js加载较慢 防止数据显示select value出来

此方法在项目中同一页面js过多的情况下会导致ie6崩溃
于是采用第二种方法

$(function(){
var type_select = $('#stEventType').combobox({
url:'sub_template/code_json.jsp?type=EVENT_TYPE',
editable:false,
valueField:'tid',
textField:'text',
onSelect:function(record){
$('#stEventName').combobox('clear');
$('#stEventName').combobox('reload','sub_template/code_json.jsp?type='+record.tid);
}
});
var sub_select = $('#stEventName').combobox({
disabled:false,
url:'sub_template/code_json.jsp?type=EVENT_TYPE_1',
valueField:'tid',
textField:'text'
});
});
EasyUI中,`combobox`是一种常用的下拉选择框组件。通过`combobox`可以实现其他单元格或组件的联动效果。以下是一个简单的示例,展示如何实现`combobox`其他单元格的联动。 假设我们有一个表格,其中一个单元格是`combobox`,另一个单元格会根据`combobox`的选择变化而变化。 首先,引入EasyUI的CSS和JS文件: ```html <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css"> <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script> <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> ``` 然后,创建一个表格,并在其中添加`combobox`和需要联动的单元格: ```html <table id="myTable" style="width: 400px;"> <tr> <th>选择项</th> <th>联动项</th> </tr> <tr> <td> <select id="myComboBox" class="easyui-combobox" name="myComboBox" style="width: 200px;"> <option value="1">选项1</option> <option value="2">选项2</option> <option value="3">选项3</option> </select> </td> <td id="linkedCell">请选择上面的选项</td> </tr> </table> ``` 接下来,添加JavaScript代码,实现`combobox`的联动效果: ```javascript $(document).ready(function() { $('#myComboBox').combobox({ onSelect: function(record) { var selectedValue = record.value; var linkedText = ''; if (selectedValue == '1') { linkedText = '你选择了选项1'; } else if (selectedValue == '2') { linkedText = '你选择了选项2'; } else if (selectedValue == '3') { linkedText = '你选择了选项3'; } $('#linkedCell').text(linkedText); } }); }); ``` 在这个示例中,当用户选择`combobox`中的一个选项时,`onSelect`事件会被触发,并根据选择的值更新`linkedCell`单元格的内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值