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

Datagrid: afterRender called twice when paging is enabled #1776

Open
kwojcikowski opened this issue Aug 23, 2024 · 1 comment
Open

Datagrid: afterRender called twice when paging is enabled #1776

kwojcikowski opened this issue Aug 23, 2024 · 1 comment
Labels
status: clarification Needs a bit of clarification type: bug 🐛 [3] Velocity rating (Fibonacci)

Comments

@kwojcikowski
Copy link

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

  • ids-enterprise-ng: 15.6.1

Platform

  • Device (if applicable) Dell laptop
  • OS Version: Windows 11
  • Browser Name: Chrome
  • Browser Version: Version 127.0.6533.122 (Official Build) (64-bit)
@tmcconechy tmcconechy changed the title Datagrid - afterRender called twice when paging is enabled Datagrid: afterRender called twice when paging is enabled Aug 23, 2024
@tmcconechy tmcconechy added type: bug 🐛 [3] Velocity rating (Fibonacci) status: clarification Needs a bit of clarification labels Aug 23, 2024
@tmcconechy
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: clarification Needs a bit of clarification type: bug 🐛 [3] Velocity rating (Fibonacci)
Projects
Development

No branches or pull requests

2 participants