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

绑定Ligerui中的ligerComboBox二级联动

时间:2014-09-17 18:11:42      阅读:5052      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   for   数据   div   

 $.ajax({
                url: "HRHandler.ashx",
                data: "bz=getDepartData",
                cache: false,
                type: "post",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function (data) {
                    if (data != null) {
                        //生成类型 下拉必须是jason字符串
                        var selectdata = eval(data);
                        t34.setData(selectdata);
                        
                        //for (var i = 0; i < selectdata.length; i++) {
                        //    $("#TextBox34").append("<option value=‘" + selectdata[i].id + "‘>" + selectdata[i].text + "</option>");
                        //}
                    }
                },
                error: function () {
                    f_alert(‘fail‘, ‘error‘)
                }
            });
            //当选择部门的时候加载二级班组,构成联动
            $("#TextBox34").change(function() {
                var departId = "";
                $("#TextBox34").ligerComboBox({ width: boxwidth ,
                    onSelected: function (newvalue)
                    {
                        departId = newvalue;

                        $.ajax({
                            url: "HRHandler.ashx",
                            data: "bz=getGroupData&departId=" + departId,
                            cache: false,
                            type: "post",
                            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                            success: function (data) {
                                var a = "[ {‘id‘:‘ ‘,‘text‘:‘ ‘}]";
                                t35.setData(eval(a));
                                
                                var selectdata = eval(data);
                                t35.setData(selectdata);
                            },
                            error: function () {
                            }
                        })
                    }
                });
            });
     //联动加载部门数据到dropdownlist
            case "getDepartData":
                DataTable dt = EDU.DBUtility.DbHelperSQL.GetDataTable("select departed_I,departName_N from DepartmentEng");
                //StringBuilder st = new StringBuilder();
                //foreach (DataRow dr in dt.Rows)
                //{
                //    st.Append("<option value=\"" + dr["departed_I"].ToString() + "\">" + dr["departName_N"].ToString() + "</option>\n");   
                //}

               string griddata = EDU.COMMON.PublicMethod.GetSelectJson(dt);
               griddata = griddata.Replace("departName_N", "text");
               griddata = griddata.Replace("departed_I", "id");
                
               context.Response.Write(griddata);
                break;

            //联动加载部门下的班组数据到dropdownlist
            case "getGroupData":
                DataTable dtGroup = EDU.DBUtility.DbHelperSQL.GetDataTable("select G.group_I,G.groupName_N from [GroupsEng] G left join [DepartmentEng] D on G.departid_I=D.departed_I where D.departed_I=" + context.Request.Params["departId"]);
                //StringBuilder stGroup = new StringBuilder();
                //foreach (DataRow dr in dtGroup.Rows)
                //{
                //    stGroup.Append("<option value=\"" + dr["group_I"].ToString() + "\">" + dr["groupName_N"].ToString() + "</option>\n");
                //}
                //context.Response.Write(stGroup.ToString());

                string griddataG = EDU.COMMON.PublicMethod.GetSelectJson(dtGroup);
                griddataG = griddataG.Replace("groupName_N", "text");
                griddataG = griddataG.Replace("group_I", "id");

                context.Response.Write(griddataG);
                break;

 

绑定Ligerui中的ligerComboBox二级联动

标签:style   blog   color   io   os   ar   for   数据   div   

原文地址:http://www.cnblogs.com/kennyliu/p/3977525.html

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