How to add row number to kendo ui grid?

前端 未结 8 1403
花落未央
花落未央 2020-12-15 09:35

I have a kendo ui grid in my page that has some columns. Now I want to add a column to it that shows me row number. How to I do this? Thanks.

8条回答
  •  没有蜡笔的小新
    2020-12-15 09:55

    For asp.net mvc wrapper you should use something like this:

    @{
         var counter = 1;
    }
    
    @( Html.Kendo().Grid()
       .Name("grid")
       .Columns(columns =>
       {           
            // Define a template column with row counter
           columns.Template(@@counter++);    
    
           // Define a columns from your data set and set a column setting
           columns.Bound(type => type.id);    
    
           columns.Bound(type=> type.name).Title("Name");    
           // add more columns here          
       })
    )
    

提交回复
热议问题