tags:

views:

248

answers:

2

I need to add a column to telerik grid which shows the serials number Please Help.. Thanks

A: 

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();
    %>
korchev
A: 

I think you are confused with my word serial number, it is not associated with any property i mean the row number to show first record ,second record like that For eg if we have two records in grid

Sl No Name Email

1 Tom [email protected]

2 JACKSON [email protected]

The first column(Slno) which shows the number in above... Pls help thanks

JIJIL
You've got 2 accounts, which is why you couldn't edit the question. Register one of the accounts and then ask the moderators (by flagging one of your own posts) to merge them.
ChrisF