Container in the collection - SeelctedItem doesn't work

Hi, I have the containers in the CUSTOM collection. Please see the picture. When I click on the container2 or button in the collection, the COLLECTIONFavourtite.SelectedItem is not updated. I have to click on the collection card to activate the card and COLLECTIONFavourtite.SelectedItem.
This behaviour is very counterintuitive.

Is there any better how to custom organise objects on the custom collection and still have SelectedItem key working?
Thank you

2023-03-14_085242 Reetool Collection and Container

Hey @riskaone!

Just to clarify here, are you seeing this behavior in both editor and preview mode or is it just in the editor?

Hi Kabirdas, thank you for your reply. I deleted this and had to use a workaround. However, I recreated the sample for you. Collection.SelectedItem attribute doesn't work on both edit and preview. The same issue is on the mobile as well.
Issue: whenever I click on the item in the collection ->->-> selectedItem is not updated. The button should show the selected item, or you should see the value in the Components View in the edit mode. Please see the attached JSON file.
Test Custom Collection.json (16.5 KB)

Ahh I see, with some testing, selectedItem seems to be working for press event handlers on the collection itself. Have you tried using i in the button's event handler instead?

Hi Kabirdas, thank you. It works. The i concept is quite strange as this is variable, not the reference to the object and its attribute. Where can I find more documentation about that, pleases?

I checked [i] on a separate screen. I need on "AddNew" screen to use defaults from the collectionView2, but using [i] always uses the first record from the collection. Please see the attached file.
Test Custom Collection (1).json (21.2 KB)

The i variable represents the index of the context it exists in. So, for instance, in your collection, it'll be the index of the button you're clicking. If you want to store that and reference it somewhere else you might try using a temporary state:

The above would store the value of the selected row so that you could reference it elsewhere:

Could that work?
Test-20Custom-20Collection-20(1).json

1 Like

Thank you Kabirdas, that works. :+1: