Jquery JQGrid显示列但不显示行数据

Jquery JQGrid显示列但不显示行数据,jquery,jqgrid,Jquery,Jqgrid,谁能帮帮我吗。我试图使用JQGrid使用json动态呈现列和数据。列似乎正在出现,但没有行数据 以下是我从服务返回的JSON: { "total": 1, "page": 1, "records": 1, "rows": [ { "id": 29291, "cell": [ "Jim", "1", "2"

谁能帮帮我吗。我试图使用JQGrid使用json动态呈现列和数据。列似乎正在出现,但没有行数据

以下是我从服务返回的JSON:

{
    "total": 1,
    "page": 1,
    "records": 1,
    "rows": [
        {
            "id": 29291,
            "cell": [
                "Jim",
                "1",
                "2"
            ]
        }
    ],
    "columns": [
        "Name",
        "30/10/2012",
        "23/10/2012"
    ],
    "columnmodel": [
        {
            "name": "Name",
            "index": "Name",
            "align": "left",
            "width": 25
        },
        {
            "name": "30/10/2012",
            "index": "30/10/2012",
            "align": "left",
            "width": 25
        },
        {
            "name": "23/10/2012",
            "index": "23/10/2012",
            "align": "left",
            "width": 25
        }
    ]
}
我使用的javascript是:

$.ajax({
    type: "GET",
    url: "ListData?ID=1",
    datatype: "json",
    success: function(result){
        $("#customgrid").jqGrid({
                datatype: "json",
                colNames: result.columns,
                colModel: result.columnmodel,
                data: result.rows,
                width: 800,
                pager: "#customgridpager",
                viewrecords: true,
                sortable: true,
                gridview: true,
        });
    },
});

任何帮助都将不胜感激。

您只需在代码中做一些小改动即可。您需要首先更改
$中的键入错误。ajax
调用:将
datatype
更改为
datatype
。然后您需要将
datatype:“json”
更改为
datatype:“jsonstring”
data:result.rows
更改为
datastr:result
。我建议您使用的完整代码如下:

$.ajax({
键入:“获取”,
url:“NiallGray.json”,
数据类型:“json”,
成功:功能(结果){
$(“#customgrid”).jqGrid({
数据类型:“jsonstring”,
colNames:result.columns,
colModel:result.columnmodel,
datastr:结果,
宽度:800,
寻呼机:“#customgridpager”,
viewrecords:是的,
可排序:是的,
gridview:没错,
行数:10000,
高度:“自动”
});
}
});
演示的修改版本为:


您只需在代码中做一些小的更改。您需要首先更改
$中的键入错误。ajax
调用:将
datatype
更改为
datatype
。然后您需要将
datatype:“json”
更改为
datatype:“jsonstring”
data:result.rows
更改为
datastr:result
。我建议您使用的完整代码如下:

$.ajax({
键入:“获取”,
url:“NiallGray.json”,
数据类型:“json”,
成功:功能(结果){
$(“#customgrid”).jqGrid({
数据类型:“jsonstring”,
colNames:result.columns,
colModel:result.columnmodel,
datastr:结果,
宽度:800,
寻呼机:“#customgridpager”,
viewrecords:是的,
可排序:是的,
gridview:没错,
行数:10000,
高度:“自动”
});
}
});
演示的修改版本为: