国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

easyui下拉框動態(tài)級聯(lián)加載的示例代碼

2019-11-19 14:49:16
字體:
供稿:網(wǎng)友

easyui的下拉框動態(tài)加載數(shù)據(jù),高校中要根據(jù)首先查詢所有學(xué)院,然后根據(jù)學(xué)院動態(tài)加載課程。下面看如何實現(xiàn)。

1.界面效果

2. html + js代碼

<span>學(xué)院名稱:</span> <input class="easyui-combobox" style="width:30%;" id="collegeName"> <span>課程名稱:</span> <input class="easyui-combobox" style="width:30%;" id="courseName"><br/> 
$(function() {       // 下拉框選擇控件,下拉框的內(nèi)容是動態(tài)查詢數(shù)據(jù)庫信息    $('#collegeName').combobox({         url:'${pageContext.request.contextPath}/loadInstitution',         editable:false, //不可編輯狀態(tài)        cache: false,        panelHeight: '150',        valueField:'id',          textField:'institutionName',             onHidePanel: function(){       $("#courseName").combobox("setValue",'');//清空課程       var id = $('#collegeName').combobox('getValue');           //alert(id);             $.ajax({       type: "POST",       url: '${pageContext.request.contextPath}/loadCourse?id=' + id,       cache: false,       dataType : "json",       success: function(data){       $("#courseName").combobox("loadData",data);            }         });           } });          $('#courseName').combobox({       //url:'itemManage!categorytbl',       editable:false, //不可編輯狀態(tài)      cache: false,      panelHeight: '150',//自動高度適合      valueField:'id',        textField:'courseName'      });     }); 

3.后臺代碼

@RequestMapping("/loadInstitution")   /**    * 加載學(xué)院    * @param     * @param     * @return void    * @exception/throws [違例類型] [違例說明]    * @see     [類、類#方法、類#成員]    * @deprecated    */   public void loadInstitute(HttpServletRequest request,       HttpServletResponse response) throws Exception {     try {       JackJsonUtils JackJsonUtils = new JackJsonUtils();       List<Institution> institutionList = institutionBean           .queryAllColleage();       System.out.println("學(xué)院list大小=====" + institutionList.size());       String result = JackJsonUtils.BeanToJson(institutionList);       System.out.println(result);       JsonUtils.outJson(response, result);     } catch (Exception e) {       logger.error("加載學(xué)院失敗", e);     }   }    @RequestMapping("/loadCourse")   /**    * 動態(tài)加載課程    *    *    * @param     * @param     * @return void    * @exception/throws [違例類型] [違例說明]    * @see     [類、類#方法、類#成員]    * @deprecated    */   public void loadCourse(HttpServletRequest request,       HttpServletResponse response) throws Exception {     JackJsonUtils JackJsonUtils = new JackJsonUtils();     String id = request.getParameter("id");     System.out.println("學(xué)院id====" + id);     try {       if(id != null && id != ""){         List<CourseInfo> listCourseInfoList = courseBean             .queryAllCourseInfos(id);         System.out.println("課程list大小=====" + listCourseInfoList.size());         String result = JackJsonUtils.BeanToJson(listCourseInfoList);         System.out.println(result);         JsonUtils.outJson(response, result);       }     } catch (Exception e) {       logger.error("加載課程失敗", e);     }   }  

根據(jù)基礎(chǔ)提供的接口查詢學(xué)院和課程,轉(zhuǎn)換為json格式后綁定到前臺控件上。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 景东| 龙里县| 米易县| 诸暨市| 凯里市| 岳阳县| 五大连池市| 普格县| 临漳县| 东丽区| 闻喜县| 惠州市| 南投县| 甘谷县| 措勤县| 卓尼县| 邮箱| 汝南县| 重庆市| 太和县| 体育| 康马县| 怀远县| 长岭县| 阿克苏市| 大城县| 建宁县| 崇州市| 肇州县| 沂水县| 全州县| 扎囊县| 同心县| 格尔木市| 措美县| 大悟县| 元朗区| 磐石市| 郯城县| 兴城市| 建瓯市|