I am trying to display data in JqGrid from spring controller.
Here is the JSON response from my spring controller {"rows":[{"firstName":"sharma","lastName":"sharma","id":2}],"page":"1","records":"1","total":"1"}
This is my jsp file:
<table id="grid"></table>
<div id="pager"></div>
<script type="text/javascript">
$("#grid").jqGrid({
url:'/url',
colModel:[
{name:'id', label: 'ID', formatter:'integer', width: 40},
{name:'firstName', label: 'First name', width: 300},
{name:'lastName', label: 'Last Name', width: 200}
],
caption: "ReportingEmployees",
pager : '#pager',
height: 'auto'
}).navGrid('#pager', {edit:false,add:false,del:false, search: false});
</script>
I have spent hours to figure out what is wrong, JSON looks valid also. Any help is much appreciated.
You need add the option
UPDATED: The demo uses JSON data which you posted and your code where I added
datatype: 'json'
. It displays