我很厭煩解決這個問題。我只想顯示兩個值,例如在columns.Foreignkey中。在相同列上顯示名稱和ID。我該怎麼做呢?請回復在劍道中顯示兩個值外鍵Grid MVC
@(Html.Kendo().Grid<Project_Test.Models.Workcenter>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.WorkcenterCode).Width(80).Title("Workcentercode").ClientTemplate("");
columns.Bound(p => p.WorkCenterSection).Width(84).Title("WorkcenterSection");
columns.ForeignKey(p => p.WorkcenterCategory, (System.Collections.IEnumerable)ViewBag.WorkcenterCategory, "WorkcenterCategoryID", "WorkcenterCategoryName")
.Title("Category").Width(200);
//command.Custom("Details").Click("showDetails").HtmlAttributes(new { @class = "k-font-icon k-i-insert-unordered-list " });
command.Custom(" ").Click("showDetails").HtmlAttributes(new { @class = "btn btn-default btn-xs glyphicon glyphicon-list-alt" });
}).Width(230);
})
// .Events(e => e.DataBound("onDataBound"))
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Workcent").DisplayDeleteConfirmation("Are you sure to delete this Workcenter"))
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.Messages(messages => messages.Refresh("Click to refresh"))
.ButtonCount(8))
.Groupable()
.HtmlAttributes(new { style = "height:580px;" })
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.Selectable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.WorkcenterID);
model.Field(p => p.WorkcenterID).Editable(true);
model.Field(p => p.UpdatedBy).DefaultValue(User.Identity.Name);
model.Field(p => p.CreatedBy).DefaultValue(User.Identity.Name);
})
.Create(update => update.Action("Employee_Create", "Home"))
.Read(read => read.Action("List", "Home"))
.Update(update => update.Action("Products_Update", "Home"))
.Destroy(update => update.Action("adress_Destroy", "Home"))
)
我不明白是什麼意思「TextOfSelectedItem」我只想在Grid中插入兩個值FK我該怎麼做,請詳細解釋 – Simo