zoukankan      html  css  js  c++  java
  • 下拉框combobox用法&级联餐单

    如果下来内容不用后台取数据,直接写死的话不用url属性,直接用data即可:

     <input id="orderstate" name="orderstate" class="easyui-combobox" />
    $(function(){
    $("#orderstate").combobox({
                    valueField: 'id',
                    textField: 'text',
                     80,
                    autoShowPanel: true,
                    data: [{ id: -1, text: '支付结果' }, { id: 1, text: '成功' }, { id: 0, text: '失败' }],
                    onLoadSuccess: function () {
                        var val = $(this).combobox('getData');
                        if (val != null && val.length > 0) {
                            $(this).combobox('select', val[0]["id"]);//val[0].id也可以
                        }
    
                    }
                });
    });

    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="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); } } } }); });
  • 相关阅读:
    neutron 多租户隔离的实现以及子网间路由的实现
    neutron是一个超级脚本的理解
    LVS + nginx实现高性能精准负载均衡
    LVS + HAProxy实现跨网负载均衡
    Linux 线程实现模型
    Linux 进程调度的主要策略
    Linux PCI设备驱动的实现思路与思想
    网络控制器intel 82599, powerpc 830的BD描述符结构
    Linux网络设备驱动的实现
    大规模分布式服务的核心思想
  • 原文地址:https://www.cnblogs.com/yonguibe/p/5501610.html
Copyright © 2011-2022 走看看