C# 我不能让它们消失的萤火虫错误

C# 我不能让它们消失的萤火虫错误,c#,asp.net-mvc-3,jquery-ui,jqgrid,C#,Asp.net Mvc 3,Jquery Ui,Jqgrid,我一直在Firebug中遇到这个错误: d未定义 [在此错误上中断]randId:function(d){return(d?d:b.jgrid…(i,d);if(g)返回d;返回d.length> 我使用JqGrid版本: 我的控制器方法如下所示: public JsonResult CategoryList(int page) { List<CategoryDTO> categories = ServiceUtil.AuctionService.ListCa

我一直在Firebug中遇到这个错误:
d未定义
[在此错误上中断]randId:function(d){return(d?d:b.jgrid…(i,d);if(g)返回d;返回d.length>

我使用JqGrid版本:

我的控制器方法如下所示:

public JsonResult CategoryList(int page)
    {
        List<CategoryDTO> categories = ServiceUtil.AuctionService.ListCategories();
        List<dynamic> json = new List<dynamic>();

        if (categories != null && categories.Count > 0)
        {
            foreach (CategoryDTO cat in categories)
            {
                json.Add(new { Id = cat.Id, Name = cat.Name, Update = cat.LastUpdate, Regex = cat.ValidationXSD });
            }
        }

        var result = new
        {
            total = 1,
            page = page,
            records = categories == null ? 0 : categories.Count,
            rows = (from cat in categories.Take(10)
                    select
                        new { Id = cat.Id, Name = cat.Name, Update = cat.LastUpdate, Regex = cat.ValidationXSD }
                    ).ToArray()
        };

        return Json(result, JsonRequestBehavior.AllowGet);

    }
$(document).ready(function () {
    $("#jqgridListCategory").jqGrid({
        url: '/Admin/ManageCategory/CategoryList',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Id', 'Name', 'LastUpdate', 'RegularExpression'],
        colModel: [{ name: 'Id', index: 'Id', width: 40, align: 'left' }, { name: 'Name', index: 'Name', width: 400, align: 'left' }, { name: 'LastUpdate', index: 'LastUpdate', width: 40, align: 'left' }, { name: 'RegularExpression', index: 'RegularExpression', width: 40, align: 'left'}],
        pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'Id',
        sortorder: "desc",
        viewrecords: true,
        caption: 'Categories'
    });
}); 
我想不出是怎么回事,有什么想法吗

编辑1:使用最新的jquery版本1.7.2


编辑2:我不希望控制器中的正则表达式只不过是视图中的字符串。
CategoryList
操作以错误的格式生成数据。您必须使用
jsonReader
或更改
CategoryList
操作的代码

服务器响应的
部分中的项的数量应如下所示

{"id" :"1", "cell": ["cell11", "cell12", "cell13"]}
如果第一列
Id
是唯一的,并且可以用作行的Id,则可以只使用数组或字符串:

rows = (from cat in categories.Take(10)
        select new[] {
            cat.Id.ToString(),
            cat.Name,
            cat.LastUpdate.ToString(),
            cat.ValidationXSD
        }).ToArray()
在jqGrid中,您应该将
key:true
添加到列“Id”的属性列表中,并添加以下jqGrid选项

jsonReader: { cell: "" }

我建议您使用my或it's from。

尝试使用其他jquery版本您使用json变量的目的是什么?在您的控制器中放置正则表达式和javascript expect RegularExpression,对吗?我使用该变量从jqgrid@Floradu88:不客气!你遇到的问题是什么在您的问题中描述的更改后仍然存在,我在回答中建议了哪些更改?我必须做一些更改,以恢复我所做的一些更改,如果有,我将接受答案works@Floradu88:好的,如果你有任何问题,你可以在这里写评论。