首页 > 其他 > 详细

下拉框combobox用法&级联餐单

时间:2016-05-17 14:49:47      阅读:190      评论:0      收藏:0      [点我收藏+]

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); } } } }); });

 

下拉框combobox用法&级联餐单

原文:http://www.cnblogs.com/yonguibe/p/5501610.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!