JqG​​rid没有显示数据

时间:2015-08-09 08:10:41

标签: javascript jquery json jqgrid grid

我正在尝试将JQgrid与当前项目一起使用来显示用户数据。我可以从服务器获取JSON数据,但它没有显示在网格中。下面是我的JqGrid初始化代码。

HTML:

<table class="table" id="useMgmtGridTbl" data-dbl-action ='@Url.Action("GetUsers", "Admin")' data-dbl-datatype='json'>
</table>
<div id="jqGridPager"></div>

JS:

jQuery("#useMgmtGridTbl").jqGrid({
        url: $("#useMgmtGridTbl").attr("data-dbl-action"),
        datatype: $("#useMgmtGridTbl").attr("data-dbl-datatype"),
        colNames: ['Id', 'User Name', 'User Type', 'Zip Code'],
        colModel: [
        { name: 'UserId', index: 'userId'},
        { name: 'UserName', index: 'userName'},
        { name: 'UserType', index: 'userType'},
        { name: 'ZipCode', index: 'zipCode' }
        ],
        rowNum: 1,
        sortname: 'id',
        viewrecords: true,
        sortorder: "desc",
        caption: "User Managment"
    });

JSON From Server:

{
    "page": 1,
    "total": 10,
    "records": 100,
    "rows": [{
        "UserId": 12,
        "UserName": "admin@gmail.com",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Admin"
    },
    {
        "UserId": 3,
        "UserName": "dipak",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Admin"
    },
    {
        "UserId": 10,
        "UserName": "doc@gmail.com",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Doctor"
    },
    {
        "UserId": 11,
        "UserName": "doc1@gmail.com",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Doctor"
    },
    {
        "UserId": 9,
        "UserName": "doctor",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": null
    },
    {
        "UserId": 4,
        "UserName": "doctor@gmail.com",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Doctor"
    },
    {
        "UserId": 5,
        "UserName": "patient",
        "UserType": 0,
        "ZipCode": null,
        "UserRole": "Patient"
    }]
}

我也尝试过不同的JsonReader,但没有运气。  JS错误输出屏幕下方:

Out put with error

任何人都可以帮我显示数据。如果需要,我可以调整JSON结果。

0 个答案:

没有答案