I have a Razor page with a Kendo grid, trying to bind to ViewData. The page is showing a syntax problem on the @(Html.Kendo().Grid line as shown below. I can't figure out why the page won't render. This is just like the example at
http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/server-binding
Dan
http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/server-binding
Dan
Controller code:
public ActionResult PatientMedInfo(long id)
{
IContextManager contextManager = ManagerConfig.GetManagerForUser(Session[SessionItems.AuthenticatedUser] as DHS.Entities.IDHSPrincipal);
IWorkContext workContext = contextManager.Begin();
DHS.Entities.Patient patient = workContext.GetPatientManager().GetById(id);
ICollection<
DHS.Entities.PatientCatheter
> catheterlog = workContext.GetPatientManager().FindCatheters(patient);
IEnumerable<
Catheter
> cats = catheterlog.Select(cat => new Catheter
{
Id = cat.Id,
CatheterType = cat.CatheterType,
EffectiveDate = cat.EffectiveDate,
DiscontinuedOn = cat.DiscontinuedOn,
Manufacturer = cat.Manufacturer,
Clinician = cat.Clinician
}).OrderBy(x => x.EffectiveDate);
ViewData["catheters"] = cats;
return View(Views.EmployeeMedInfo, CPR.WebPortal.Models.PatientMedInfo.Populate(workContext, workContext.GetPatientManager().GetById(id)));
}
Razor page:
@model PatientMedInfo
@(Html.Kendo().Grid((IEnumerable<
Catheter
>)ViewData["catheters"])
.Name("CatheterGrid")
.Columns(columns =>
{
columns.Bound(e => e.CatheterType.Name).Title("Type");
columns.Bound(e => e.EffectiveDate).Title("Placed On").Format("{0:d}");
columns.Bound(e => e.DiscontinuedOn).Title("Discontinued On");
columns.Bound(e => e.Manufacturer.Name).Title("Manufacturer");
columns.Bound(e => e.ClinicianDisplayName).Title("Clinician");
columns.Bound(e => e.Id).Hidden();
columns.Bound(e => e.Id).ClientTemplate(
"<
a
href
=
'" + Url.Action("EditCatheter", Controllers.Patient) + "/#= Id #'
" + "
class
=
'btn btn-sm'
>Edit</
a
>"
).Width(80).Title("");
})
.Pageable(pageable => pageable
.PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
.ButtonCount(5))
.Sortable()
.Filterable()
.Scrollable()
.ClientDetailTemplateId("template")
.ToolBar(toolbar =>
{
toolbar.Template(@<
text
>
<
div
style
=
"float:right"
>
<
a
href
=
'@Url.Action("EditCatheter", Controllers.Patient)/0'
class
=
'btn btn-sm'
>New</
a
>
</
div
>
</
text
>);
})