EasyUI 笔记(1)第一次在项目中使用纠结死了

来源:互联网 发布:爱淘宝返利多少 编辑:程序博客网 时间:2024/05/21 08:43

1.datebox 

html标签

 <input type="text" id="StartTime" class="easyui-datebox" style="width: 150px;" />

设置为当前时间

$(function () {
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();//+ "-";
            //strDate += curr_time.getHours() + ":";
            //strDate += curr_time.getMinutes() + ":";
            //strDate += curr_time.getSeconds();
            $("#StartTime").datebox("setValue", strDate);


        });

获取控件中时间

 $("#StartTime").datebox("getValue") 


2.下拉列表


html标签

 <select id="sk" onchange="changeSK()"></select>

JS函数

 function LoadSK() {
            $.ajax({
                url: "YBZDFWXZPage.aspx?action=loadSK&Random=" + Math.random(),
                type: 'POST',
                success: function (data) {
                    $("#sk").append(data);
                    $("#sk").get(0).selectedIndex = 1;
                }
            });
        }


后台代码

 #region 获得水库
        /// <summary>
        /// 获得水库
        /// </summary>
        private void LoadSK()
        {
            StringBuilder sbOption = new StringBuilder();
            DataSet ds = _BLL.GetSK();
            if (null != ds && ds.Tables.Count > 0)
            {
                if (null != ds.Tables[0] && ds.Tables[0].Rows.Count > 0)
                {


                    sbOption.Append("<option value=\"-1\">请选水库</option>");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string stcd = ds.Tables[0].Rows[i]["STCD"].ToString();
                        string stnm = ds.Tables[0].Rows[i]["STNM"].ToString();
                        string sttp = ds.Tables[0].Rows[i]["STTP"].ToString();
                        sbOption.Append("<option value=" + stcd + ">" + stnm + "</option>");
                    }
                }
            }
            Response.Write(sbOption);
            Response.End();
        }
        #endregion


以上为最简单的控件使用


0 0
原创粉丝点击