EasyUI- combobox implements drop-down list year display

 EasyUI implementation: combobox implements a drop-down list to display the year

1. jsp page:

 

<input  title="年份" style="width: 99%;" type="text" name="feeDate" id="feeDate" value=""/>
<script type="text/javascript">
    //Initialization data
    $(function(){
	 //Initialize the year
	 $('#feeDate').combobox({    
	    url:'orgbuild/party/djpartydues/djPartyDuesController/operation/queryYearList.json',
	    valueField:'yearId',    
	    textField:'yearName'   
	 });  	
    });
</script>

 2. java code

/**
 * Get a list of years
 * The current year and 10 years ahead of the year data
 */
@RequestMapping(value = "/operation/queryYearList")
public ModelAndView queryYearList(HttpServletRequest request, HttpServletResponse response) throws Exception{
	//Get the records of the current year and the previous 10 years
	 String newYear = DateUtils.getYear();
	 int currentYear = Integer.parseInt(newYear);	    
        String date = "[";
        for(int i=0; i<10; i++){
	  String yearId = Integer.toString(currentYear);
	  String yearName = Integer.toString(currentYear)+"年";
	  date += "{\"yearId\":\"" + yearId + "\",\"yearName\":\"" + yearName + "\"}";
	    if(i<9){
		  date +=",";
	    }
	     currentYear--;  
	  }
	 date += "]";
         response.setCharacterEncoding("UTF-8");
	 PrintWriter out = response.getWriter();
	 out.write(date);
	 out.close();
	 return null;
}

 

   

//return json
// [{"yearId":"2017","yearName":"2017年"},{"yearId":"2016","yearName":"2016年"},{"yearId":"2015","yearName":"2015年"},{"yearId":"2014","yearName":"2014年"},{"yearId":"2013","yearName":"2013年"},{"yearId":"2012","yearName":"2012年"},{"yearId":"2011","yearName":"2011年"},{"yearId":"2010","yearName":"2010年"},{"yearId":"2009","yearName":"2009年"},{"yearId":"2008","yearName":"2008年"}]

  

 

   Display of results:


 
 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326991502&siteId=291194637