primeng icon indicating copy to clipboard operation
primeng copied to clipboard

rowIndex is not updating when a row is removed from Datatable

Open Nattujessy opened this issue 9 years ago • 10 comments

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

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.

http://plnkr.co/edit/4oBtDrIFRx1ORfcOp8BJ?p=preview

Current behavior

Datatable row index is not updating properly when a row is removed.

Expected behavior

Update the rowIndex when model has been changed.

Minimal reproduction of the problem with instructions

Just click "Delete Row" button in in middle of given plunker

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 4.0.0
  • PrimeNG version: 4.0.0.rc.1
  • Browser: [all ]
  • Language: [all | TypeScript 2.2 | ES6/7 | ES5]

  • Node (for AoT issues): node --version =
    @angular/cli: 1.0.0 node: 6.9.5 os: win32 x64

Nattujessy avatar Mar 31 '17 10:03 Nattujessy

Hi, the solution that worked for me was to encode the data then decode it so it will hold no reference to the changed array. JSON.decode(JSON.encode(array)) should work.

UCKFA avatar Mar 31 '17 12:03 UCKFA

Hi, thanks for your interest. Am using typescript class and methods to compute few runtime values. if i encode and decode into json object then the class may not have methods and results an error

Nattujessy avatar Mar 31 '17 14:03 Nattujessy

Any updates for this issue ?

Nattujessy avatar Apr 03 '17 05:04 Nattujessy

This also creates a problem with a grouped DataTable.

Brampage avatar Apr 04 '17 19:04 Brampage

Same problem here: I have to insert/delete/reorder rows.

Also note that, when you delete row # 4 in the linked plnkr for instance, and afterwards row # 5, then # 6 is removed because it is the 5th element in the backing array. This is a showstopper for me.

My versions are:

@angular/cli: 1.0.0
node: 7.8.0
os: win32 x64
@angular/*: 4.0.1

BastiOfBerlin avatar Apr 07 '17 08:04 BastiOfBerlin

I've replicated but cannot find a solution right now.

cagataycivici avatar Apr 13 '17 23:04 cagataycivici

Hi @cagataycivici, AFASK am updating here, i have forked the same plunkr http://plnkr.co/edit/86PPOwshePXzIsxGDtmH?p=preview with html table. here the index property is changed when a row gets deleted. i think the problem is primeng index property is not gets bind properly.

i may not given a exact solution but i hope this is something relevant.

Nattujessy avatar Apr 17 '17 11:04 Nattujessy

Any updates @cagataycivici?

BastiOfBerlin avatar May 05 '17 07:05 BastiOfBerlin

Same issue here. The rowIndex is not being updated when deleting a row.

MakhouT avatar May 15 '17 09:05 MakhouT

Same issue here.

hoisel avatar May 24 '17 16:05 hoisel