我试图使用jqGrid的相当复杂的用户界面。网格最终需要有一个下拉列,一个自动完成和一个按钮列。目前,我无法确定如何设置一个包含select
列的列,该列在我的模型中填充IEnumerable
的值,设置来自模型属性的初始选定值,并在用户更改时更改该属性列表的值为select
。例如,说我有这些模型:jqGrid列与模拟Html.DropDownListFor选择列表
public class GridRowModel
{
public int GridRowModelId { get; set; }
public string SomeText { get; set; }
public int SomeSelectOptionId { get; set; }
}
public class SelectOption
{
public int SomeSelectOptionId { get; set; }
public string Description { get; set; }
}
public class SomeModel {
public int SomeModelId { get; set; }
public IEnumerable<GridRowModel> GridRowModels { get; set; }
public IEnumerable<SelectOption> AllSelectOptions { get; set; }
}
的SomeModel
的AllSelectOptions
属性被设置在控制器,与模型其他事情一样。控制器还有一个方法GetSomeModelGridRows
,返回jqGrid rows
的GridRowModel
对象数组。然后,我有剃刀,看起来是这样的:
@model SomeModel
<table id="someModelGridRows" cellpadding="0" cellspacing="0"></table>
<div id="pager" style="text-align: center;"></div>
<script type="text/javascript">
$(document).ready(function() {
$("#someModelGridRows").jqGrid({
url: '@Url.Action("GetSomeModelGridRows")',
datatype: 'json',
mtype: 'POST',
colNames: ['GridRowModelId', 'Text', 'Select Option'],
colModel: [
{ name: 'GridRowModelId', index: 'GridRowModelId', hidden: true },
{ name: 'SomeText', index: 'SomeText' },
{ name: 'SomeSelectOptionId', index: 'SomeSelectOptionId', edittype: 'select',
**?? is this where I would do something and if so, what ??**
],
//the rest of the grid stuff
});
});
</script>
在非电网的情况下,这将使用Html.DropDownListFor
帮手简单。有什么方法可以在此使用?我是否会以这种错误的方式去做这件事,甚至有可能吗?