绑定Ligerui中的ligerComboBox二级联动

 $.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;

 

文章来自:http://www.cnblogs.com/kennyliu/p/3977525.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3