Primeng: Feature Request - enable index on the new DataView

Created on 2 May 2018  路  4Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[ X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap

Current behavior
I am displaying a list using the new DataView. I am trying to access the index of the item being displayed like so

<p-dataView [value]="items" [paginator]="true" [rows]="20">
        <p-header>My List</p-header>
        <ng-template let-item let-i="index" pTemplate="listItem">
            <div>
                <childA *ngIf="item.type === 'typeA' " [item]="item" [index]="i"></childA>
                <childB *ngIf="item.type === 'typeB' " [item]="item" [index]="i"></childB>
        </ng-template>
    </p-dataView>

I expect to be able to access the the index i of each item as before in the dataList. However this does not work with the new dataView.

Most helpful comment

When paginator is used, rowIndex starts with "0" again for every page instead of index of the object in array. Say array has 4 elements and each page contains 2 elements.
<ng-template let-car pTemplate="listItem" let-i="rowIndex"> <h1> {{i}} </h1>

the above code results in 0,1 and 0,1 on pagination instead of 0,1,2,3

All 4 comments

This is already a feature.
If you check the demo and change the code below like this, you can access and display the index.
```

....

{{i}}

This is available.

When paginator is used, rowIndex starts with "0" again for every page instead of index of the object in array. Say array has 4 elements and each page contains 2 elements.
<ng-template let-car pTemplate="listItem" let-i="rowIndex"> <h1> {{i}} </h1>

the above code results in 0,1 and 0,1 on pagination instead of 0,1,2,3

@cagataycivici Any update on this? As @sarikaK945 mentioned, this added feature has a bug when dataview is used with pagination.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garethlewis picture garethlewis  路  3Comments

mitosandov picture mitosandov  路  3Comments

KannanMuruganmony picture KannanMuruganmony  路  3Comments

SchneMa picture SchneMa  路  3Comments

miresk picture miresk  路  3Comments