Alexander, I do have the template there and I put a breakpoint there to ensure it was hitting it.
So this is what I have:
The View:
@(Html.Kendo().Grid<
HRIT.Models.UserExclusionViewModel
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.ForeignKey(p => p.ApplicationId, (System.Collections.IEnumerable)ViewData["applications"], "ApplicationId", "Name")
.Title("Application").Width(150);
columns.Bound(p => p.Field).Width(100);
columns.Bound(p => p.Criteria).Width(100);
columns.Bound(p => p.ExclusionValue).Width(100);
columns.Command(command => command.Destroy()).Width(90);
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
model.Field(p => p.ApplicationId).DefaultValue(1);
})
.PageSize(20)
.Create(create => create.Action("ExclusionPopup_Create", "Feed"))
.Read(read => read.Action("ExclusionPopup_Read", "Feed"))
.Update(update => update.Action("ExclusionPopup_Update", "Feed"))
.Destroy(destroy => destroy.Action("ExclusionPopup_Destroy", "Feed"))
)
)
The Controller
public ActionResult Exclusion()
{
PopulateApplications();
return View();
}
And
private void PopulateApplications()
{
var dataContext = new HRITEntities1();
var applications = dataContext.Applications
.Select(a => new ApplicationViewModel
{
Id = a.Id,
ApplicationId = a.Id,
Name = a.Name
})
.OrderBy(e => e.Name);
ViewData["applications"] = applications;
ViewData["defaultApplication"] = applications.First();
}