Forum
15:17
17/12/2013
Hi, The below is the jqgrid code.
I am able to pass the request to spriong mvc controller.
But I am unable to view the data in jqgrid.
Plese find the mistake in it. It eating hours of time.
-----------------------------------------------------------------------------
var urlRequest = "emp.html";
$("#projectTable").jqGrid('setGridParam',{url:urlRequest,datatype: 'json', page:1}).trigger("reloadGrid");
$("#projectTable").jqGrid({
url: urlRequest,
datatype: 'json',
mtype: 'POST',
colNames:['First Name','Last Name', 'Address'],
colModel:[
{name:'firstName',index:'firstName', width:100,sortable:true},
{name:'lastName',index:'lastName', width:100,sortable:true},
{name:'address',index:'address', width:500,sortable:true}
],
jsonReader : {
repeatitems: false ,
records: "records",
total: "total",
page: "page",
root: "rows"
},
rowNum:5,
sortname: 'firstName',
viewrecords: true,
pager: "#pagingDiv",
height:'auto',rowList:[5,10],
loadonce: true
});
------------------------------------------------------------
Controller code:
--------------------------------------
@RequestMapping(value="/emp", method = RequestMethod.POST)
@ResponseBody
public JqGridData<Person> getPeople(){
List<Person> personList = new ArrayList<Person>();
personList.add(new Person("Sue", "Green", "207 Old Stree, Clevedon"));
personList.add(new Person("Jane", "Adams", "216 Park Road, Clevedon"));
personList.add(new Person("David", "Smith", "185 Old Kent Road, Clevedon"));
personList.add(new Person("Adam", "Davies", "18 Knowles Road Clevedon"));
int totalNumberOfRecords = 4;
int pageNumber = 1;
int numberOfRows = personList.size();
JqGridData<Person> gridData = new JqGridData<Person>(numberOfRows, pageNumber, totalNumberOfRecords, personList);
return gridData;
}
--------------------------------------
Thanks,
Pavan Jayam
Most Users Ever Online: 715
Currently Online:
36 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66