Asp.net mvc 3 MVC3 JQGrid从控制器动态设置colmodel
我已经看过很多关于在视图中设置colmodel的例子,但是我还没有看到控制器代码! 我正试图这样做,但设置一直是错误的。 我正试图达到以下专栏形式:Asp.net mvc 3 MVC3 JQGrid从控制器动态设置colmodel,asp.net-mvc-3,jqgrid,Asp.net Mvc 3,Jqgrid,我已经看过很多关于在视图中设置colmodel的例子,但是我还没有看到控制器代码! 我正试图这样做,但设置一直是错误的。 我正试图达到以下专栏形式: colModel: [ { name: 'ID', index: 'ID', hidden: true }, { name: 'Votes', index: 'Votes', width: 100, align: 'left' }, { name: 'Question', index: 'Question', width:
colModel:
[
{ name: 'ID', index: 'ID', hidden: true },
{ name: 'Votes', index: 'Votes', width: 100, align: 'left' },
{ name: 'Question', index: 'Question', width: 300, align: 'left' },
{ name: 'my_clickable_checkbox', index: 'my_clickable_checkbox',
sortable: true,
formatter: chkFmatter, formatoptions: { disabled: false }, editable: true,
edittype: "checkbox"
}
],
这是我在控制器中的试用:
return Json(
new { colNames = new[] { "ID2", "Votes2", "Question2", "checkbox" },
colModel = new[] {
new { name = "ID", index = "ID", width = 0, formatter="",
edittype="", hidden = true },
new { name = "Votes", index = "Votes", width = 100, formatter="",
edittype="", hidden = false },
new { name = "Question", index = "Question", width = 300, formatter="",
edittype="", hidden = false },
new { name = "checkbox", index = "my_clickable_checkbox", width = 100,
formatter="chkFmatter", edittype="checkbox", hidden = false }
}
}, JsonRequestBehavior.AllowGet);
在控制器中创建此数组迫使我在所有行中具有相同数量的属性。例如,我只需要隐藏ID
,但它强制我向所有其他列提供hidden
属性
第二个问题,我需要为第四列调用js函数chkFmatter
我怎样才能到达控制器中的colModel队列
非常感谢。您可能对jqGrid功能感兴趣。它允许您将整个jqGrid配置导入或导出到另一种文件格式或从中导出 您可以阅读以下博文: