• Easyui combobox 怎么加载数据


    说明:开发环境 vs2012 asp.net mvc4 c#

    1、效果图

    2、HTML代码

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EasyuiCombotree.aspx.cs" Inherits="MvcAppTest.EasyuiCombotree" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>Easyui Combotree 测试</title>
        <link href="Easyui/themes/default/easyui.css" rel="stylesheet" />
        <script src="Easyui/jquery-1.7.2.js"></script>
        <script src="Easyui/jquery.easyui.min.js"></script>
        <script src="Easyui/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript">
            $(function () {
                $('#cc').combobox({
                    url: 'Home/getOffice',
                    valueField: 'id',
                    textField: 'text',
                    required: true,
                    queryParams: { OFFID: 100 },
                    editable: false,//不可编辑,只能选择
                    disabled: false,
                    value: '选择部门'
                });
            });
            function getValue()
            {
                var value = $('#cc').combobox('getValue');
                alert(value);
            }
            function getText()
            {
                var text = $('#cc').combobox('getText');
                alert(text);
            }
        </script>
    </head>
    <body>
      <input id="cc" name="dept" value=""    />       
      <div><input type="button" value="获取Value的值" style="100px;" onclick="getValue()"/>&nbsp;&nbsp;&nbsp;<input type="button" value="获取text的值" onclick="getText()" style="100px;" /></div>  
    <div style="height:30px;"></div>
    <span>combobox 另一种定义形式</span>
    <div>
    <select id="Select1" class="easyui-combobox" name="dept" style="200px;">
        <option value="aa">aitem1</option>
        <option>bitem2</option>
        <option>bitem3</option>
        <option>ditem4</option>
        <option>eitem5</option>
    </select>
    </div>
    </body>
    </html>


    3、Home后台代码

            public JsonResult getOffice(string OFFID)
            {
                 Int32 officeID = Convert.ToInt32(OFFID);
                List<ComboModel> myList = new List<ComboModel>();          
            
                    for (int i = 1; i < 20; i++)
                    {
                        ComboModel model = new ComboModel()
                        {
                          id=i,
                           text="部门"+i.ToString()
                        };
                        myList.Add(model);
                    }
    
                
                return Json(myList, JsonRequestBehavior.DenyGet);
            }
       public class ComboModel
        {
            public System.Int32 id { get; set; }
            public System.String text { get; set; }
        }
  • 相关阅读:
    关于apache的动态与静态编译
    使用awk处理正则表达式时注意事项
    fedora下apache默认配置
    vim显示行号、语法高亮、自动缩进的设置
    简单介绍apahce内存管理机制
    处理路径上的小技巧
    Educational Codeforces Round 80 (Rated for Div. 2)
    web前端页面性能优化小结
    web标准—可用性、可维护性、可访问性
    雅虎团队经验:网站页面性能优化的 34条黄金守则
  • 原文地址:https://www.cnblogs.com/net064/p/10275598.html
Copyright © 2020-2023  润新知