【发布时间】:2015-02-27 04:45:38
【问题描述】:
如果有人能就我的问题提出建议,我将不胜感激。 我有一个包含集合的模型:
public class Customer
{
public Customer()
{
this.CustomerAddresses = new HashSet<CustomerAddress>();
}
//..properties
public virtual ICollection<CustomerAddress> CustomerAddresses {get; set;}
}
在我的“创建”视图中,我有一个带有 incell 编辑的网格,它允许我存储 CustomerAddress 的集合,然后与 Customer 模型一起传递给控制器:
@model Customer
//Customer inputs...
@( Html.Kendo().Grid(Model.CustomerAddresses)
.Name("CustomerAddresses")
.ToolBar(toolbar => { toolbar.Create(); })
.Columns(columns =>
{
columns.Bound(p => p.AddressID).Hidden();
columns.Bound(p => p.Type) //Foreign key of type string
.EditorTemplateName("DropDownTemplate")
.EditorViewData(new { ddname = "Type" })
.ClientTemplate("#= Type #" +
"<input type='hidden' name='CustomerAddresses[#= index(data)#].Type' value='#= Type #' />");
columns.Bound(p => p.Region) //Foreign key of type int?
.EditorTemplateName("DropDownTemplate")
.EditorViewData(new { ddname = "Region" })
.ClientTemplate("#= Region #" +
"<input type='hidden' name='CustomerAddresses[#= index(data)#].Region' value='#= Region #' />");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.DataSource(dataSource =>
dataSource.Ajax()
.Model(model =>
{
model.Id(u => u.AddressID);
})
))
下拉模板:
@if (ViewData["ddname"] == "Region")
{
@Html.Kendo().ComboBox().Name(ViewData["ddname"].ToString())
.BindTo(SelectListProvider.GetCatalog<Region>())
}
else
{
@Html.Kendo().ComboBox().Name(ViewData["ddname"].ToString())
.BindTo(SelectListProvider.GetCatalog<AddressType>())
}
问题是,当我从Region 整数列的下拉列表中选择一些项目并在单元格外按时,它不会将所选值分配给网格列。我看到一个空单元格。
但是,当我在 Type 单元格中选择字符串并按下外部时,我看到了选定的值。
我做错了什么? int 列有什么问题?
非常感谢
【问题讨论】:
标签: jquery asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc