mariuszfoltak/angular2-datatable

Increment index on page change

Closed this issue · 1 comments

lginq commented
<tr *ngFor="let item of mf.data; let idx = index">
                    <td>
                        {{ idx + 1 }}
                    </td>
                    <td>{{item.name}}</td>
                    <td>{{item.email}}</td>
                    <td class="text-right">{{item.age}}</td>
                    <td>{{item.city | uppercase}}</td>
</tr>

Right now index is always 1-10, on every page

oosor commented

...
{{ (mf.activePage - 1) * mf.rowsOnPage + idx + 1 }}
...

object mf DataTable (example)

activePage: 1
data: Array[10]
diff: DefaultIterableDiffer
differs: IterableDiffers
inputData: Array[11]
mustRecalculateData: false
onPageChange: EventEmitter
onSortChange: ReplaySubject
rowsOnPage: 10
sortBy: ""
sortByChange: EventEmitter
sortOrder: "asc"
sortOrderChange: EventEmitter