infor-design / enterprise-ng

Angular wrappers for IDS Enterprise components
Apache License 2.0
58 stars 83 forks source link

Datagrid: afterRender called twice when paging is enabled #1776

Open kwojcikowski opened 2 months ago

kwojcikowski commented 2 months ago

Describe the bug What I am trying to achieve is to use an array of ids to indicate which rows should be selected on a datagrid. My assumption was to use afterRender hook and go through that array and select corresponding rows. Also, when manually selecting/deselecting records I want to update the array to I used selected hook. This is what happens:

  1. Datagrid is loaded, afterRender is triggered with the source below: image

  2. Rows are selected based on an array

  3. Now, settingsChanged is triggered, which causes the datagrid to rerender

  4. When datagrid is rerendered I believe a deselctall is triggered which clears my array because of selected hook

  5. The afterRender is triggered (source below). Now I am unable to select the desired records because the array has been cleared. image

Expected behavior There could be couple of solutions. What I think would be best is to have a hook similar to renrered that will trigger after the datagrid is fully initialized including paging etc.

Current workaround I have managed to find a workaround to this issue and trigger the selection on 2nd afterRender but this is really not the greates way to approach this

Version

Platform

tmcconechy commented 2 months ago

Not sure if we can fix the afterRender from calling as it may render twice with paging (one the empty grid then the one with pages).

Other ideas to take an array of selected ids and select them

a) In the data mark each row to be selected on the _selected field i.e. `dataset: [{..., _selected: true}) b) Populate the _selectedRows array on the grid c) after loading the data in the next statement called selectRow(idx) instead of afterrender

AAlviar commented 1 week ago

IDS Jira: https://inforwiki.atlassian.net/browse/IDS-4176