I have a problem to render column template with Telerik Grid for MVC. I’m currently using the last version : 2011.3.1115.340 with ASP.NET MVC 3 (Razor view engine)
This the code of my view page :
@{
Html.Telerik().Grid<CustomerModel>()
.Name("CustomersGrid")
.DataKeys(keys =>
{
keys.Add(c => c.Id);
})
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new {style = "margin-left:0"}))
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Select("_SelectBinding", "Customers")
.Insert("_InsertBinding", "Customers")
.Update("_SaveBinding", "Customers")
.Delete("_DeleteBinding", "Customers");
})
.Columns(columns =>
{
columns.Bound(c => c.Id).Width(20).ReadOnly(true);
columns.Bound(c => c.Email);
columns.Bound(c => c.Lastname);
columns.Bound(c => c.Firstname);
columns.Bound(c => c.MobilePhone);
columns.Bound(c => c.EnterpriseName);
columns.Bound(c => c.ManagementComments);
columns.Bound(c => c.IsActivated);
columns.Template(
@<text>
<div>@item.Id</div>
</text>
).Title("Premium");
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.ClientEvents(events => events.OnComplete("Grid_onComplete")).Render();
}
I have the template column “premium” in my grid but it’s still empty :
http://www.imagup.com/data/1140161102.html
I also test without the Render(), same result :
@(Html.Telerik().Grid<CustomerModel>()
... blabla ...
columns.Template(
@<text>
<div>@item.Id</div>
</text>
).Title("Premium");
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.ClientEvents(events => events.OnComplete("Grid_onComplete"))
)
Thanks for your help !
Your grid is ajax bound which means that server-side templates are not applied. Use the ClientTemplate instead: