欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2017年11月29日 16:37:08   作者:9_張曉  
本篇文章主要介紹了easyui下拉框動(dòng)態(tài)級(jí)聯(lián)加載的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

easyui的下拉框動(dòng)態(tài)加載數(shù)據(jù),高校中要根據(jù)首先查詢所有學(xué)院,然后根據(jù)學(xué)院動(dòng)態(tài)加載課程。下面看如何實(shí)現(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)容是動(dòng)態(tài)查詢數(shù)據(jù)庫(kù)信息 
   $('#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',//自動(dòng)高度適合 
     valueField:'id',   
     textField:'courseName' 
     }); 
    
}); 

3.后臺(tái)代碼

@RequestMapping("/loadInstitution") 
  /** 
   * 加載學(xué)院 
   * @param  
   * @param  
   * @return void 
   * @exception/throws [違例類型] [違例說(shuō)明] 
   * @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") 
  /** 
   * 動(dòng)態(tài)加載課程 
   * 
   * 
   * @param  
   * @param  
   * @return void 
   * @exception/throws [違例類型] [違例說(shuō)明] 
   * @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格式后綁定到前臺(tái)控件上。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論