Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete rows, as duplicate IDs are getting created #495

Closed
SumeetKumarBarua opened this issue Jun 13, 2020 · 3 comments · Fixed by #497
Closed

Unable to delete rows, as duplicate IDs are getting created #495

SumeetKumarBarua opened this issue Jun 13, 2020 · 3 comments · Fixed by #497

Comments

@SumeetKumarBarua
Copy link

General Topic

Your Environment

Software Version(s)
Angular 7.3.9
Angular-Slickgrid 2.17.4
TypeScript 3.2.2
Operating System MacOS
NPM/Node/Yarn 6.9.0

Context or Topic

Slickgrid has existed since long, but doing it the Angular way was
really fun. Thanks to the Team.
I was trying out the feature of add / update
https://ghiscoding.github.io/Angular-Slickgrid/#/additem and
its really cool. But some how it was generating duplicate IDs as a
result of which I was not able to delete the rows. I was going through
its demo component
https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-additem.component.ts
and figured in line no: 167 const newId = this.dataset.length;. I
understand its a very minor issue but newbie might struggle a bit at
start if they follow the Demo component.

Expected Behavior

Should generate unique IDs.

Current Behavior

Row IDs are repeating. I have attached a gif for the same.
slickgrid-add

Possible Solution

Could use a min heap to get the missing IDs.
But we can simply use the below as we just need to mention some unique ID:
let length = this.dataset.length;

let id = (length === 0) ? len : this.dataset[length-1].id + 1

@ghiscoding
Copy link
Owner

ghiscoding commented Jun 16, 2020

Ok thanks for the hint even though users will never (at least they shouldn't) use this piece of code as it's only for demo purposes, however your code change doesn't seem to work correctly. A better fix is to find the highest Id of the dataset and increment by 1, that is what I've done in the PR #497, I'm also pulling latest dataset from the DataView so it's updated.

VGntJKOPbh

@SumeetKumarBarua
Copy link
Author

Thanks for looking into it :)

@ghiscoding
Copy link
Owner

This is now fixed in latest version 2.19.x.

Please upvote ⭐ if you haven't already.
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants