swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

Checkbox unchecks automatically with TimerObservable #1017

Open Shiiboun opened 7 years ago

Shiiboun commented 7 years ago

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

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior I am updating my data every 5 sec and reciving it like this: this.subscription = TimerObservable.create(0, 5000) .subscribe(() => this.ngZone.run(() => { this.getData(); }));

Now everytime I get my data, the checkbox I selected is getting unchecked. Is there any way to avoid this behavior?

I tried to work with trackByProp but aint got that working.

Edit: It also happens with my detail-row

Expected behavior The checkbox is still checked even if I get new/updated data.

chouclee commented 6 years ago

You need to implement rowIdentity() function for your specific use case. Your request will return brand new instances each time so the table thought they are different rows. https://swimlane.gitbooks.io/ngx-datatable/content/api/table/inputs.html

Edit: that solution is only for checkbox. RowDetails can't be fixed

kowalczm commented 6 years ago

So there is no chance to have it working for RowDetails? Any workaround would be great

chouclee commented 6 years ago

@kowalczm
Please check https://github.com/swimlane/ngx-datatable/pull/975 Whenever row changes, rowDetails will be cleared. There is no workaround as for now.