Reputation: 29
Can anyone tell me how to fetch data from a controller returning data of type hashmap into jqgrid?
This is what i have tried. Its entering into a infinite lop
$(document).ready(function(){
$("#datatable").jqGrid({
url:"${pageContext.request.contextPath}/employees",
cache: false,
colNames:["id","name","age","salary","address","laptop"],
colModel:[
{name:"id",index:"id", width:60},
{name:"name",index:"name", width:90},
{name:"age",index:"age", width:100},
{name:"salary",index:"salary", width:80, align:"right"},
{name:"address",index:"address", width:80,
align:"right"},
{name:"laptop",index:"laptop", width:80,align:"right"}
],
mtype: "GET",
rownumbers: true,
rownumWidth: 40,
gridview: true,
caption: "Hashmap Data"
});
});
Controller Part
@RequestMapping(value="/employees", method = RequestMethod.GET)
public ModelAndView listEmployees() {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
for (Entry<String, Object> entry : model.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
System.out.println("hello key, " + key + " value " + value);
}
return new ModelAndView("employeesList", model);
}
example: employees value [1 ram 22 12234 usa yes, 6 abc 25 23889 xyz, yes]
Please someone help me in solving this. its giving parse error: invalid xml message
Upvotes: 0
Views: 529
Reputation: 323
Maybe you are missing on datatype
key in the jqgrid options
Check what does your url ${pageContext.request.contextPath}/employees
returns? and specify the same data type in another option datatype
According to the documentation the default value of datatype
is xml
.
Try changing it to json
Upvotes: 2