首页 > 代码库 > 绑定Ligerui中的ligerComboBox二级联动
绑定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 =http://www.mamicode.com/ eval(data); t34.setData(selectdata); //for (var i = 0; i < selectdata.length; i++) { // $("#TextBox34").append("<option value=http://www.mamicode.com/‘" + 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 =http://www.mamicode.com/ 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=http://www.mamicode.com/"" + dr["departed_I"].ToString() + "\">" + dr["departName_N"].ToString() + "</option>\n"); //} string griddata =http://www.mamicode.com/ 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=http://www.mamicode.com/"" + 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二级联动
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。