问题
I have the following markup in a 'content' page. Without the Render call, nothing renders, and with the Render call, the grid renders as the first element in the whole page, not inside the 'content' section defined by my view:
@using Telerik.Web.Mvc.UI
@model Outdoor.Mvc.ViewModels.OutdoorSite.SiteList
@{
Html.Telerik().Grid(Model.ItemList).Name("Site Grid")
.Columns(columns =>
{
columns.Bound(o => o.SiteId);
columns.Bound(o => o.Name);
})
.Pageable()
.Sortable()
.Render();
}
What am I doing wrong?
回答1:
This is because of different approach to rendering Razor's views. In order to make it work you have to remove Render() call and build grid in multiline expression block, like this:
@using Telerik.Web.Mvc.UI
@model Outdoor.Mvc.ViewModels.OutdoorSite.SiteList
@(
Html.Telerik().Grid(Model.ItemList).Name("Site Grid")
.Columns(columns =>
{
columns.Bound(o => o.SiteId);
columns.Bound(o => o.Name);
})
.Pageable()
.Sortable()
)
来源:https://stackoverflow.com/questions/4458753/problem-rendering-telerik-mvc-grid-in-a-razor-view