1、单个下拉框:
<td> <input id="waytype" name="waytype" class="easyui-combobox" /></td>
$(function () { var _actiontype = $(‘#waytype‘).combobox({ type: "GET", dataType: ‘json‘, url: "/xxxx/xxxx.json", editable: false, valueField: ‘id‘, textField: ‘text‘, onSelect: function (record) { }, onLoadSuccess: function (data) { if (data.length == 0) { $.messager.alert("系统提示", "数据库异常,请联系管理员!", "warning"); } else { var data1 = $(‘#waytype‘).combobox(‘getData‘); //赋默认值 if (data1.length > 0) { $("#waytype").combobox(‘select‘, data1[0].actionid); } } } }); });
2、级联餐单:
<td> <input id="actiontype" name="actiontype" class="easyui-combobox" style="width:80px" /></td> <td> <input id="waytype" name="waytype" class="easyui-combobox" /></td>
$(function () { var _actiontype = $(‘#actiontype‘).combobox({ type: "GET", dataType: ‘json‘, url: "/xxx/xxx.json", editable: false, valueField: ‘actionid‘, textField: ‘actionname‘, onSelect: function (record) { //以下是根据第一个餐单选择值不同而去获取不同的二级连餐单,如果只是简单的根据第一个餐单值而去获取对应的数据源,不需要判断直接获取就ok了 if (record.actionid == "get") { _waytype.combobox({ disabled: false, url: ‘/xxx/GetWayTypeJson1‘, valueField: ‘id‘, textField: ‘text‘ }).combobox(‘clear‘); } else { _waytype.combobox({ disabled: false, url: ‘/xxx/GetWayTypeJson2‘, valueField: ‘id‘, textField: ‘text‘ }).combobox(‘clear‘); } }, onLoadSuccess: function (data) { if (data.length == 0) { $.messager.alert("系统提示", "数据库异常,请联系管理员!", "warning"); } else { var data1 = $(‘#actiontype‘).combobox(‘getData‘); //赋默认值 if (data1.length > 0) { $("#actiontype").combobox(‘select‘, data1[0].actionid); } } } }); var _waytype = $(‘#waytype‘).combobox({ editable: false, disabled: false, valueField: ‘id‘, textField: ‘text‘, onLoadSuccess: function (data) { if (data.length == 0) { $.messager.alert("系统提示", "数据库异常,请联系管理员!", "warning"); } else { var data1 = $(‘#waytype‘).combobox(‘getData‘); //赋默认值 if (data1.length > 0) { $("#waytype").combobox(‘select‘, data1[0].id); } } } }); });
时间: 2024-10-17 06:04:45