【发布时间】:2014-02-22 09:21:14
【问题描述】:
我正在使用编辑器模板来编辑记录。但是我在绑定字段中添加外键列,添加新按钮停止工作,但编辑工作正常。这是我的代码。
@(Html.Kendo().Grid<TelerikMvcTestApp.Models.VM.ReferralViewModel>()
.Name("grid")
.Columns(c =>
{
c.Bound(i => i.ReferralDate).Title("Date");
c.ForeignKey("AssignedMD.ID", (SelectList)ViewData["UserList"]).Title("Assigned MD").Width(200); // When I comment this line, then It works fine
c.Command(cmd =>
{
cmd.Edit();
cmd.Destroy();
});
})
.HtmlAttributes(new { style = "height: 500px;" })
.Scrollable()
.Groupable()
.Sortable()
.ToolBar(tb => tb.Create())
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("ReferralEdit"))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource =>
dataSource
.Ajax()
.ServerOperation(true)
.PageSize(10)
.Model(model =>
{
model.Id(i => i.ID);
model.Field(i => i.ID).Editable(false);
model.Field(i => i.AssignedMD.ID).DefaultValue(1);
})
.Create(i => i.Action("ReferralCreate", "Referral"))
.Read(i => i.Action("ReferralRead", "Referral"))
.Update(i => i.Action("ReferralUpdate", "Referral").Type(HttpVerbs.Post))
.Destroy(i => i.Action("ReferralDelete", "Referral"))
当我评论这一行时,它工作正常
c.ForeignKey("AssignedMD.ID", (SelectList)ViewData["UserList"]).Title("Assigned MD").Width(200);
【问题讨论】:
标签: c# asp.net-mvc telerik kendo-grid