DataGrid selectedrows

Hi everyone, i hope you’re doing fine !

I’m currently working on a datagrid with checkboxes, and i’d like to have some of the checkboxes checked already when the page is loaded but unfortunately i can’t find a way to initialize the Datagrid selected row variable.

Anyone can help me with this ?

Hello, for now you’ll have to work it out based on this solution, there seems to currently not be a way to set this up in a simpler way.

I’ve tried but doesnt work. Basically Xano shows me which lines should be selected, my workflow is similar as the one you showed me: changing the value of the data grid selected variable with JS and then change page. When i test the workflow it seems to work but nothing changes…
Any idea ?

Here is the workflow i’ve used + the formula i’ve used to make it fit the format of the variable.


I’m not sure whether after page change you can execute any javascript this way. If you can, then you might want to look at how the data looks in the datagrid and make your data follow the structure.

Screenshot 2023-09-05 at 17.06.52

If you check this out, I for example have Unique id set to email. So when I check the id it’s actually an email. Might be that you are using an id from xano, but have not bound that same id from xano as Unique id?

I just tried it and it works. Make sure your ids are bound, and then just do as in the guide I sent you.

I’ve sent my unique id to id of my collection item, and I’m inserting the same id (I have ids from 1 to 6) as an array

That is exactly what i did. That is why i added a JS funciton so the format is the same. Here are the screen of what my datagrid selectedrow looks like and what i’m returning for when i change it’s value. It’s still doesnt change…


Capture d'écran 2023-09-05 182331

The page rotation form is where the datagrid is displayed. I’ve tried changing it before and after changing page it still doesnt work even though it says that the operation succeded, it’s really werid …

1 Like

Thanks a lot for this explanation and thanks for your time :grinning:

1 Like

Hey,

I’m sorry to re open this topic, but I’ve tried many times your solution in my project and it still doesnt work…

I’ve done exactly what you’ve showed me, but it seems that on page load the value of the SelectedRow doesnt change, i dont really get why it doesnt work here are a few screen: the first one is what i do with the dump array, the second one is what i do on page load and the third one is the selectedRow variable whenever i select some rows.



Capture d'écran 2023-09-08 101833

Do you have the id bound to DataGrid unique id?

You also might try to remove the returns, in my code I think I wasn’t using them, so that might be the difference as well

I only put the returns to show you what were the values, I still doesnt work with ti. and yes i’ve got the id bound to Datagrid unique id :frowning:

Hmm, I tried it and it seems like it works for me with my test data. The selected rows on your last screenshot is after changing it via JavaScript?

It’s kinda tough to debug it like this. If you want we can hop on a videocall so you can share me your screen.

Nah it’s when i select them manually ! I’m down to hop on a videocall whenever you’re free

I see now, yeah, this is a workaround that works for displaying the selected data, but it seems like the DataGrid has it’s own state, so this doesn’t seem to work, dang… I’m afraid you’ll have to wait for WeWeb team to expose the variable on this one… I see the issue now, and I’m not sure if this is doable in this case.

Arghhhh thanks for your time anyway

1 Like

(post deleted by author)