0

ngx-datatable rowIndex is starting from 0

When i display list using ngx-datatable rowIndex is coming from 0, can we make it start from 1.

<ngx-datatable
    #table
    class="bootstrap table table-bordered"
    [columns] = "columns"
    [columnMode]="'force'"
    [headerHeight]="50"
    [footerHeight]="35"
    [rowHeight]="'auto'"
    [limit]="listLimit"
    [rows]="tutors">

  <ngx-datatable-column name="S No.">
    <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-row="row">
      {{rowIndex}}
    </ng-template>
  </ngx-datatable-column>

</ngx-datatable>
Mohammad Fareed
  • 1,927
  • 6
  • 26
  • 59

1 Answers1

4

ngx-datatable rowindex starts from 0. You can increment the rowindex by 1 in the html while displaying.

Please refer the code below.

<ngx-datatable
    #table
    class="bootstrap table table-bordered"
    [columns] = "columns"
    [columnMode]="'force'"
    [headerHeight]="50"
    [footerHeight]="35"
    [rowHeight]="'auto'"
    [limit]="listLimit"
    [rows]="tutors">

  <ngx-datatable-column name="S No.">
    <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-row="row">
      {{rowIndex+1}}
    </ng-template>
  </ngx-datatable-column>

</ngx-datatable>
Narayanan Ramanathan
  • 1,310
  • 10
  • 18