Announcement Announcement Module
Collapse
No announcement yet.
jqGrid in Spring MVC Web App Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jqGrid in Spring MVC Web App

    Dear Friends.,
    I make a jqGrid in my Spring Webapp. But it not show datas.i posted it in many forums also. but not solved yet.
    please help me.i need it for my final year project.

    i want to display citys list in grid.there was 3 records at the database at the moment..
    here is my codings..

    i make a Grid.java
    Code:
    public class Grid {
    		private String page;
    		private String total;
    		private String records;
    		private List rows = new ArrayList();
    & Getter,Setters

    Here is my cityGridView method in CityController
    Code:
    @RequestMapping(value = "/cityGridView", method = RequestMethod.GET)
    	public @ResponseBody Grid selectHarbour(Map<String, Object> map,HttpServletRequest request, HttpServletResponse response){
    	Grid grid = new Grid();
    	grid.setPage("1");
    	grid.setTotal("1");
    	grid.setRecords("2");
    	List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
    	List <City> list = cityService.listCity();
    	for(City city:list){
    	Map<String, Object> dataRow = (Map<String, Object>) rows.get(0);
    	dataRow.put("id", city.getCityId());
    	dataRow.put("code", city.getCityCode());
    	dataRow.put("name", city.getCityName());
    	list.add((City) dataRow);
    	}
    	grid.setRows(list);
    	return grid;
    	}
    & Finally here is my jQuery codes in jsp

    Code:
    <table id="list5"></table> 
    <div id="pager5"></div>
    <script type="text/javascript">
    jQuery("#list5").jqGrid({ 
    	url:'cityGridView.html', 
    			datatype: "json", 
    			colNames:['City Id','City Code', 'City Name'], 
    			colModel:[ 
    			           {name:'cityId', width:55}, 
    			           {name:'cityCode', width:90}, 
    			           {name:'cityName',width:100}
    			          ], 
    			     rowNum:10, 
    			     rowList:[10,20,30], 
    			     pager: '#pager5',
    			     jsonReader: {
    			    	 cell: "rows",
    			    	 repeatitems: false
    			    	 },
    			     sortname: 'id', 
    			     viewrecords: true, 
    			     sortorder: "desc", 
    			     caption:"City List View", 
    			     editurl:"" 
    			    }).navGrid("#pager5",
    			    		{edit:false,add:false,del:false}); 
    			    		jQuery("#a1").click( function(){ 
    			    			var id = jQuery("#list5").jqGrid('getGridParam','selrow'); 
    			    			if (id) { 
    			    				var ret = jQuery("#list5").jqGrid('getRowData',id); 
    			    				alert("id="+ret.id+" invdate="+ret.invdate+"..."); 
    			    				} else { alert("Please select row");} 
    			    			});
    </script>
Working...
X