Hi there,
I have a collection, and I have the items from that collection represented in a gallery. I have added a trash icon to delete the selected record. But for some reason when I click in the trash icon the record deleted is not the selected record instead the first record in the gallery is deleted.
Any help with the right formula?
Thanks in advance
Solved! Go to Solution.
So the problem why this wasn't working for you was because there was nothing unique in the Collection items used to populate the gallery. So whenever you were trying to remove a item, it would just delete the first row since all rows were identical.
All we have to do ss to add a unique ID when adding the locations to a collection. This can be done using a button to add locations from the Locations gallery into a collection by setting the OnSelect property of that button to Collect(CollectionName, {Title: ThisItem.Title, ID: num+1), Set(num, num+1)
Also, we need to initialise the variable num to zero on the OnVisible property of the screen.
Now what will happen is every time a location is added to the collection, the ID field of that entry will be unique. Now when you will use Remove(CollectioName, ThisItem) it will work properly.
Hope this helps!
---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!
Hardit(Haman)
Hi,
Thank you very much for your prompt reply.
I am probably doing something wrong, because is not working, I have a gallery where I have added a button to create a new collection, because I need some items form previous gallery plus new more items. I have applied your solution but nothings happens.
Regards.
Sorry, I am not an expert.
I am trying to build something like a Purchase Order. and I have a customer and locations.
Once I have selected the customer I have to choose the first location and add the items for that location, like a shopping cart.
Now that location came from another gallery. So I placed a button to add the first location into a new collection then I have added some dropdown boxes plus some others fields.
Make sense or too confused?
Thanks
I am trying to remove the location and the items associated with that location, I mean the entire record
So the problem why this wasn't working for you was because there was nothing unique in the Collection items used to populate the gallery. So whenever you were trying to remove a item, it would just delete the first row since all rows were identical.
All we have to do ss to add a unique ID when adding the locations to a collection. This can be done using a button to add locations from the Locations gallery into a collection by setting the OnSelect property of that button to Collect(CollectionName, {Title: ThisItem.Title, ID: num+1), Set(num, num+1)
Also, we need to initialise the variable num to zero on the OnVisible property of the screen.
Now what will happen is every time a location is added to the collection, the ID field of that entry will be unique. Now when you will use Remove(CollectioName, ThisItem) it will work properly.
Hope this helps!
---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!
Hardit(Haman)
User | Count |
---|---|
136 | |
133 | |
78 | |
72 | |
69 |
User | Count |
---|---|
222 | |
136 | |
78 | |
60 | |
54 |