我的应用中有一个Telerik MVC网格:
@(Html.Kendo().Grid<SkillCardViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Width("5%");
columns.Bound(p => p.LastModified).Visible(false).Width("15%");
columns.ForeignKey(p => p.EmployeeID, new SelectList((IEnumerable)ViewData["employees"], "ID", "Login")).Title("Employee").Width("25%");
columns.ForeignKey(p => p.SkillCategoryID, new SelectList((IEnumerable)ViewData["skillcategories"], "ID", "Name")).Title("Skill Category").Width("25%");
columns.ForeignKey(p => p.SkillID, new SelectList((IEnumerable) ViewData["skills"], "ID", "Name")).Title("Skill").Width("25%");
columns.ForeignKey(p => p.RatingID, new SelectList((IEnumerable)ViewData["ratings"], "ID", "Name")).Title("Rating").Width("15%");
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width("15%");
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Excel();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.Scrollable()
.Groupable(groupable => groupable.Enabled(true))
.Filterable(x =>
{
x.Enabled(true);
x.Mode(GridFilterMode.Menu);
})
.Excel(excel => excel
.FileName("CTG_ScoreCard.xlsx")
.Filterable(true)
)
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events =>
{
events.Error("error_handler");
events.RequestEnd("requestend_handler");
})
.ServerOperation(true)
.Model(model =>
{
model.Id(p => p.ID);
model.Field(p => p.ID).Editable(false);
model.Field(p => p.SkillCategoryID).Editable(true);
model.Field(p => p.SkillID).Editable(true);
model.Field(p => p.LastModified).Editable(false);
model.Field(p => p.RatingID).Editable(true);
})
.Create(create => create.Action("SkillCard_Create", "Scorecard", new { area = "Scorecard", @id = ViewBag.EmployeeID }))
.Read(read => read.Action("SkillCard_Read", "Scorecard", new { area = "Scorecard", @id = ViewBag.EmployeeID }))
.Update(update => update.Action("SkillCard_Update", "Scorecard", new { area = "Scorecard", @id = ViewBag.EmployeeID }))
.Destroy(destroy => destroy.Action("SkillCard_Destroy", "Scorecard", new {area = "Scorecard", @id = ViewBag.EmployeeID}))
)
)
数据正在正确加载到网格中,当我尝试创建或编辑记录时,我希望Skill Category
下拉列表过滤掉Skills
记录,因此只有所选类别的技能。我怎样才能做到这一点?