How Can I Have Row Number In Kendo UI Grid

前端 未结 7 2146
悲&欢浪女
悲&欢浪女 2020-12-10 18:15

I have kendo grid in asp.net mvc and i use server wrapper.I want Additional column named \"Row Number\" that is simple counter (1,2,3,...). I want this counter never change

相关标签:
7条回答
  • 2020-12-10 19:15

    Other answers are OK but they don't apply pagination effects. So I think better implementation would be:

    var grid = $( "#grid" ).kendoGrid( {
        sortable: true,
        dataSource: [ {
            name: "Jane Doe",
            age: 30
        }, {
            name: "John Doe",
            age: 33
        } ],
        pageable: {
            refresh: false,
            pageSizes: true,
            pageSize: 10,
        },
        columns: [ {
            field: "name"
        }, {
            field: "age"
        }, {
            field: "rowNumber",
            title: "Row number",
            template: dataItem => grid.dataSource.indexOf(dataItem) + 1
        } ],
    } ).data().kendoGrid;
    
    0 讨论(0)
提交回复
热议问题