JqGrid is not able to display data

2019-09-19 08:20发布

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.

1条回答
走好不送
2楼-- · 2019-09-19 08:54

You need add the option

datatype: 'json'

UPDATED: The demo uses JSON data which you posted and your code where I added datatype: 'json'. It displays

enter image description here

查看更多
登录 后发表回答