- My goal: I have a table and I want to pass the IDs of the selected rows via the query string (searchParams)
- Issue: My table default keys is
{{ (url.searchParams.deal_ids || "").split("-").map(Number) }}
; it works in the editor, but when I deploy the app (click PLAY icon) and request a url with the same params as the editor, nothing is selected in the table (a select element that is also set as default via the query string do work) - Steps I've taken to troubleshoot: if I click to see other page of the app, and then click back to get to the original page; then rows are correctly pre-selected
- Additional info: I'm using cloud; I can reproduce it every time.
Hey @Martin_Sarsale_terres , Welcome to the forum community,
I’ve gone through your issue and built a demo replicating the exact scenario you described. After testing, I was able to solve it successfully with the following approach:
- Global Variable Setup
- I created a global variable named
selectedRow
with the initial value set to0
.
- Table Event Handling
- In the table’s row selected event handler, I updated the transformer variable so that
selectedRow
={{ table1.selectedDataIndex }}
.
- Managing URL Parameters
- I added another event handler to set the URL hash parameters.
- Specifically, I set the key as
deal_ids
and the value as{{ table1.selectedDataIndex }}
.
- Default Row Selection
- Inside the Default Row section of the table, I included a condition:
{{ url.hashParams.deal_ids ? Number(url.hashParams.deal_ids) : null }}
- This ensures that when the page reloads or is shared, the table automatically highlights the correct row based on the
deal_ids
hash param.
- Navigation Handling
- While handling navigation to another page, I also passed the hash params so they persist.
- For example: key =
"deal_ids"
and value ={{ selectedRow.value }}
.
After applying these steps, I tested the setup in both Edit mode and Preview (play button) mode, and everything worked perfectly.
I’ve attached a short screen recording showing the flow in action, along with the test app JSON so you can try it out directly.
Video Recording:
App JSON:
Testing app 2.json (38.6 KB)
Hopefully this helps you replicate the solution on your side. Let me know if you hit any roadblocks—I’ll be glad to guide you further.
thanks for your reply; can you try reloading the browser tab on the second url with the hashParams?
this is the case that's failing on my side: when opening a new tab with the app url and the hashParams, rows are not selected in the table.
@Martin_Sarsale_terres It’s working for me even when I do a hard reload on page2 or open the page2 URL in a new tab—the selected table rows persist. Let me know if I’m missing anything.
Just checking in to see how things are going on your end. Were you able to solve the issue you mentioned earlier, or are you still running into the same (or perhaps a different) problem?