【发布时间】:2011-12-26 15:25:45
【问题描述】:
我在 Firebug 中不断收到此错误:d is undefined
[Break On This Error] randId:function(d){return(d?d:b.jgrid....(i,d);if(g)return d;return d.length>
我使用 JqGrid 版本:4.3.1
我的控制器方法如下所示:
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:我不希望控制器中的正则表达式在视图中只是一个字符串
【问题讨论】:
-
尝试使用其他jquery版本
-
你用json变量做什么?
-
在你的控制器中你把Regex和javascript期望RegularExpression,对吗?
-
我正在使用该变量从 jqgrid 返回所有数据
标签: c# asp.net-mvc-3 jquery-ui jqgrid