Problem displaying Telerik MVC grid in Razor mode

I have the following markup on the content page. Without calling Render, nothing is displayed, and when calling Render, the grid is displayed as the first element on the entire page, and 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?

+3
source share
1 answer

This is due to a different approach to the presentation of Razor. To do this, you need to remove the Render () call and build the grid in a multi-line expression block, for example:

@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()
)
+5
source

Source: https://habr.com/ru/post/1780628/


All Articles