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

Easyui combobox 怎么加载数据

时间:2019-01-16 11:41:52      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:image   加载   inpu   sheet   tree   图片   cal   png   meta   

说明:开发环境 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="width:100px;" onclick="getValue()"/>&nbsp;&nbsp;&nbsp;<input type="button" value="获取text的值" onclick="getText()" style="width:100px;" /></div>  
<div style="height:30px;"></div>
<span>combobox 另一种定义形式</span>
<div>
<select id="Select1" class="easyui-combobox" name="dept" style="width: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; }
    }

 

Easyui combobox 怎么加载数据

标签:image   加载   inpu   sheet   tree   图片   cal   png   meta   

原文地址:https://www.cnblogs.com/net064/p/10275598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!