国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 南安市| 五寨县| 布尔津县| 长汀县| 德钦县| 阳曲县| 吉隆县| 社旗县| 聊城市| 武义县| 沙雅县| 那曲县| 垣曲县| 丰顺县| 平安县| 泰安市| 大宁县| 邵东县| 阳城县| 洪雅县| 绵竹市| 苍梧县| 清新县| 保山市| 平武县| 定远县| 德保县| 高邑县| 清苑县| 宾川县| 中山市| 历史| 商丘市| 广南县| 莎车县| 乐清市| 阳西县| 茌平县| 台安县| 刚察县| 淮滨县|