本文主要是介绍EasyUI Combobox 级联查询,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在维护市委组织部项目的时候,使用了级联组合框,维护的时候是Asp.net,纯三层架构+Aspx页面+ashx(一般处理程序),在重构市委组织部项目的时候,用到了ITOO的框架,在ITOO4.1项目中熟悉了基本的框架,组织部项目中搭了三次框架,对框架的理解更深刻了一些;
ITOO框架,前台使用MVC,在页面cshtml和Controller之间传值,实现级联组合框,代码和维护时候的一样;
前台页面代码:
单位类别:<input id ="unitCategory" class="easyui-combobox" name ="cc" data-options="method:'get',valueField:'id',textField:'text',url:'/CadresRate/queryCategory',panelHeight:'auto',onSelect:function(rec) //rec表示被选择的内容,把id值传到controller中; {var url ='/CadresRate/queryUnitName?id=' +rec.id ;$('#unitName').combobox('reload',url); //重新加载单位名称的组合框;}
"/>单位名称<input id ="unitName2" class ="easyui-combobox" name ="cc" data-options="panelHeight:'auto',valueField:'id',textField:'id'" />
Controller中代码:
页面加载查询出所有的单位类别;
#region queryCategory + 查询单位类型 范晓权 2016年2月26日/// <summary>/// 查询单位类型;/// </summary>/// <returns></returns>public JsonResult queryCategory(){//定义一个字典的ViewModelBasicDictionaryViewModel vBasicDictionary = new BasicDictionaryViewModel(){//表示设置vBasicDictionary.DictionaryType = 5DictionaryType = 5};//调用服务器的查询类型的方法;List<BasicDictionaryViewModel> basicDictionary = IBasicDictionary.queryType(vBasicDictionary);//选择字典id 和 基础信息var unitCategory = from c in basicDictionaryselect new{id = c.DictionaryName,text = c.BasicInfoType};return Json(unitCategory, JsonRequestBehavior.AllowGet);} #endregion
<pre name="code" class="csharp"> #region queryUnitName 根据单位类别查询单位名称;/// <summary>/// queryUnitName/// </summary>/// <returns></returns>public JsonResult queryUnitName(){string type = Request["id"].ToString();//if (type == "xsq"){List<CityBasicInfoViewModel> cityBasicInfoList = ICityBasicInfo.queryAllCity();var tempCityBasicInfoList = from c in cityBasicInfoListselect new{id = c.CityID,text = c.CityName};return Json(tempCityBasicInfoList, JsonRequestBehavior.AllowGet);}else if (type == "szdw"){List<UnitBasicInfoViewModel> unitBasicInfoList = IUnitBasicInfo.queryAllUnit();var tempUnitBasicInfoList = from p in unitBasicInfoListselect new{id = p.UnitID,text = p.UnitName};return Json(tempUnitBasicInfoList, JsonRequestBehavior.AllowGet);}else if (type == "kfq"){List<DevelopmentBasicInfoViewModel> developmentBasicInfoList = IDevelopmentBasicInfo.queryAllDevelopment();var tempDevelopmentBasicInfoList = from a in developmentBasicInfoListselect new{id = a.DevelopmentID,text = a.DevelopmentName};return Json(tempDevelopmentBasicInfoList, JsonRequestBehavior.AllowGet);}else{return null;}}
效果图:
总结:
这篇关于EasyUI Combobox 级联查询的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!