Power Apps How to delete selected SPO list items in the gallery|Batch deletion with multiple selections

I was often asked how to delete selected items in the gallery control, so here’s a note.

スポンサーリンク

Advance preparation

This time, an SPO list was used as the data source.

The items of this list are displayed in Power Apps and removed using the Remove function.

Remove singular item

First, remove singular item.

When deleting the trash icon in the gallery, the formula would look like this.
Now, when you press the trash icon for the “999” item, the data on the data source side will disappear as well.
By the way, the contents of OnSelect on the item side as “Select(Parent)”,
It is possible to achieve this by writing a similar expression in OnSelect on the Parent side (gallery side).
※However, “Select(Parent)” should be removed from OnSelect for controls in the gallery that you do not want the delete action when pressed, such as OnSelect for labels.
Pressing the trash icon for the “888” item will also delete the “888” item on the data source side.
It can also be deleted by using “ThisItem” instead of “GalleryName.Selected”.
I’m writing an equation as follows, and I press the trash can icon on the “777” item,
It will also be removed from the data source.

Delete multiple selected items with checkboxes

If you place checkboxes in a gallery like this and want to delete multiple checked items at the same time,
The formula for the “delete” button is as follows
Now check “555”, “777” and “999” and press the delete button,
All data from the data source can also be deleted.

Keep selected items in a collection and delete them all at once

To the collection initialized by OnVisible on the screen,
When items in the selected gallery are added/deleted and the selection state is maintained,
※Visible of the icon representing the selection state is the following expression
The formula for deletion in this case is as follows
Select the items “444”, “666”, and “888” and press the “Delete” button,
It can also be deleted from the data source.

Is the “ForAll” function unnecessary for bulk deletion? As described in this article, the Patch and Remove functions can specify a table as the second argument, so ForAll is not necessary.

Related Articles

コメント

Copied title and URL