0

我正在尝试从 spring 控制器在 JqGrid 中显示数据。这是我的 spring 控制器的 JSON 响应{"rows":[{"firstName":"sharma","lastName":"sharma","id":2}],"page":"1","records":"1","total":"1"}

这是我的jsp文件:

<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>

我花了几个小时来找出问题所在,JSON 看起来也有效。任何帮助深表感谢。

4

1 回答 1

1

您需要添加选项

datatype: 'json'

更新演示使用您发布的 JSON 数据和我添加的代码datatype: 'json'。它显示

在此处输入图像描述

于 2013-09-16T18:41:38.860 回答