I开发者_运维技巧 need to add a column to telerik grid which shows the serials number Please Help.. Thanks
You can use a bound column if the serial number is a regular property exposed by the object the grid is bound to:
<%= Html.Telerik().Grid<MyObject>()
.Name("MyGrid")
.Columns(columns =>
{
columns.Bound(o => o.SerialNumber);
});
%>
If you need some custom formatting applied you can define a template for that column:
<% Html.Telerik().Grid<MyObject>()
.Name("MyGrid")
.Columns(columns =>
{
columns.Bound(o => o.SerialNumber).Template(o =>
{
%>
<strong><%= o.SerialNumber %></strong>
<%
});
})
.Render();
%>
And finally if you are using ajax or web service binding and need customization - use the ClientTemplate:
<% Html.Telerik().Grid<MyObject>()
.Name("MyGrid")
.Columns(columns =>
{
columns.Bound(o => o.SerialNumber)
.ClientTemplate("<strong><#= SerialNumber #></strong>");
})
.Render();
%>
精彩评论