jqGrid从url选项获取数据

时间:2013-02-26 20:39:42

标签: asp.net-mvc-4 jqgrid

我正在努力从我的网址中提取数据并将其放入我在asp.net MVC4中的jqGrid中。我在这里缺少什么?

    $(document).ready(function () {
        jQuery("#frTable").jqGrid ({
            cmTemplate: { sortable: false },
            caption: '@TempData["POPNAME"]' + ' Population',
            url: '@Url.Action("GetAjaxPagedGridData", "Encounters", new { popId = TempData["POPULATIONID"] })',//'/Encounters/GetAjaxPagedGridData/'+ '',
            datatype: "jsonstring",
            mtype: 'GET',
            pager: '#pager',
            height: '450',
            ...

然后你进入colNames和colModels以及与这个特殊的inquiery相关的所有东西......这是返回我的数据的方法......足以说明我做客户端的事情分页似乎有效。但我无法验证,除非我能真正看到数据?我在这里做错了什么?

    public string GetAjaxPagedGridData(int page, int rows, int popId) {
        string userID = HttpContext.User.Identity.Name;
        DataRepository dr = new DataRepository();
        string encounter = dr.Get(popId, userID, "1", page, rows, "");
        return encounter;
    }

1 个答案:

答案 0 :(得分:0)

您可以在

格式中使用jqGrid的postData选项
postData: {
    popId: 123
}

或表格

postData: {
    popId: function () {
        return 123;
    }
}

您应该使用datatype: "json"而不是datatype: "jsonstring"