我有一个看起来像的剑道网格:
@(Html.Kendo().Grid<UserHolidayRightDto>()
.Name("gridHoliday")
.ToolBar(tool=>tool.Create())
.Columns(columns =>
{
columns.Bound(p => p.Date).Format("{0:MM/dd/yyyy}").Title("Date added");
columns.Bound(p => p.ValidForYear).Title("For year");
columns.ForeignKey(p => p.RightTypeId,
System.Collections.IEnumerable)
@Model.HolidayRightsView, "Id", "Name").Title("Right type").HtmlAttributes(new
{@Id="HolidayRightsDropDown"});
columns.Bound(p => p.Days).Title("Days");
columns.Bound(p => p.Comment).Title("Comment");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.Scrollable(s=>s.Height(200))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Events(e=>e.Edit("edit"))
.Events(e=>e.DataBound("onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.ValidForYear).Editable(false).DefaultValue(@DateTime.Now.Year);
model.Field(p => p.Date).Editable(false);
})
.Events(e=>e.RequestEnd("UpdateWindow"))
.Read(read=>read.Action("ReadData","HolidayRights",new {id=@Model.Employee.PersonID}))
.Create(update => update.Action("EditingInline_Create", "HolidayRights",new
{personId=@Model.Employee.PersonID}))
.Update(update => update.Action("EditingInline_Update", "HolidayRights"))
.Destroy(update => update.Action("EditingInline_Destroy", "HolidayRights"))
))
我想让我的外键列在创建模式下可编辑并在编辑模式下禁用。我试过这样的解决方案: $("#HolidayRightsDropDown").attr("readonly", true);
或 var d = document.getElementById("HolidayRightsDropDown"); d.disabled =真;
或 closecell() - 但此功能仅适用于单元格编辑但没有成功。
有什么建议么?