码迷,mamicode.com
首页 > 其他好文 > 详细

下拉框combobox用法&级联餐单

时间:2016-05-17 14:51:29      阅读:198      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!