swimlane / ngx-datatable

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

Refresh data on hidden ngx-DataTable #1713

Open HermannBergqvist opened 5 years ago

HermannBergqvist commented 5 years ago

I'm submitting a ...

[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 When updating a data doing the refresh with the this.rows=[...this.rows] in a hide DataTable when unhide the object its disappear all columns and rows.

Expected behavior Its expected to return the DataTAble with the data updated with all columns and rows.

Reproduction of the problem There´s an example at http://plnkr.co/edit/tPxBDPqQfP9tArN6BB29?p=info. Just following the steps of the buttons and then you will reproduce the problem.

What is the motivation / use case for changing the behavior? The possibilty to change the data in datatable when the table is hided, it's very comum if you are doing changes in a form view after selecting a specific row.

Please tell us about your environment: Versão: 1.29.1 (system setup) Commit: bc24f98b5f70467bc689abf41cc5550ca637088e Data: 2018-11-15T19:13:36.375Z Electron: 2.0.12 Chrome: 61.0.3163.100 Node.js: 8.9.3 V8: 6.1.534.41 Arquitetura: x64 Windows 10

sarora2073 commented 5 years ago

Hi,

If you use *ngIf="!doHidden" instead of [hidden]="doHidden" it appears to work as shown here:

http://plnkr.co/edit/pRqpUkE4smApwIipgqmv

Regards,

elliotwesoff commented 3 years ago

Can confirm this issue still stands, although for me the issue only occurs when the column mode is set to 'force'. Standard column mode refreshes the table as expected. Here is my reproduction:

https://stackblitz.com/edit/ngx-datatable-refresh-rows-issue

@sarora2073 your suggestion isn't preferable because ngIf destroys the component completely when the condition becomes false. This causes the state of the table to be lost (filters, selected items, etc.), and the API endpoint for fetching the data is hit every time the table is created.

Bump!!!!!!!!

bowler-man commented 2 years ago

issue is still happening, have not found a workaround yet

beavelar commented 2 years ago

Workaround I've found is to reset the data when the component is shown.

If you have access to some onShow method or could create some sort of onShow method that is triggered each time the display is focused, reset the data, ex.: this.datatable.data = [...this.datatable.data].

You could also try calling the recalculate method from ngx-datatable and see if that provides better results. Might be worth calling if it's possible that the display can change dimensions while the datatable is hidden.