JqGrid is not able to display data

佐手、 提交于 2019-12-12 06:00:33

问题


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:


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



来源:https://stackoverflow.com/questions/18834742/jqgrid-is-not-able-to-display-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!