How to Select MULTIPLE Items in Power Apps Gallery & PATCH - ID Card Make

How to Select MULTIPLE Items in Power Apps Gallery & PATCH - ID Card Make Hello everyone razza here in this video I will show you how to multi select items from a power apps Gallery we will leverage the checkbox control to allow the user to select multiple items.

How to Select MULTIPLE Items in Power Apps Gallery & PATCH

Provide a check all option to select all the items and allow the user to make modifications to the data for all the selected items in one go by using a single patch function.

So let's check this out in action I have a gallery in my power app that is connected to a data source in my scenario the data source is a very.

Simple SharePoint list now to give the user the ability to select multiple items from a gallery I will go ahead and edit the gallery and in this Gallery I will go.

And insert the check box control this checkbox I'll position it on the left hand side the text property for the checkbox I'll set it to empty.

The checkbox has a checkbox size property I will change this to 20 also there is a focus border thickness property I will set to zero if I preview you can see each of my.

Gallery items has the option for the user to select the item by using the checkbox now whenever the checkbox is checked I would like to store the information of that selected record in a.

Collection so for the on check property of the che checkbox I will write the formula collect to collect data in a collection that I will call call data and I would like to collect this.

Item which is the current item that the user selects remember the items of the gallery are coming directly from my connected data.

Source when the checkbox is unchecked so on unchecked I would want to go ahead and remove that item from The Collection now I am using a SharePoint.

List as part of my data source the key aspect to take note of is that every SharePoint list there is a primary key and that in SharePoint is always the ID column that's the unique.

Identifier for every record on uncheck I I would like to remove the item from The Collection I'll use the formula remove if from the.

    Collection and the condition is the - ID Card Make

    Primary key which is ID is it equal to this item do ID so this will remove the data from the collection if the ID matches the current running ID of the.

    Item for the checkbox that I uncheck so now if I was to preview the app and let's say I make a couple of selections if I go to variables and look at collections here is my collection.

    Called call data that has two rows and I can view the information in this collection the two rows in the collection are the two records that I have checked if I select another one now.

    My collection has three rows if I uncheck this time my collection has one row another property of the checkbox control is the default property and that.

    Should depend upon whether the current running items primary key which in my case ID is it in that collection so the formula will be this item do ID is in my collection..

    ID now if you would like to show how many items are currently checked I'll go ahead and insert a text label control here I will say selected item count is.

    Count rows of the data in the collection so right now I have one item selected as I start selecting more items you can see the count.

    Increases and I can go go ahead and unselect as well I also want to give the user the ability to select all items at once to do that I will go and insert another checkbox.

    Control position it right here the text for this I will call it check all this checkbox I will rename to check all on check of this check boox I would like to go ahead and select all the.

    Items in the gallery my Galler items

    Property is my SharePoint list the formula that I've written on the items property I will copy this and for my checkbox all on check I will use the.

    Formula clear collect in my collection called call data and for the item I will simply put that same formula that I copied from the items property of the gallery so basically all I'm saying here.

    Is go collect all the data from my data source and put it in the collection on uncheck of the check all checkbox I would simply go and clear the data in that.

    Collection so let's try this check you can see it's gone ahead and checked all the items are my gallery uncheck removes it all when I select check all the.

    Collection item count says 500 however if I add another label control here to show the gallery item count which I can get by pointing to the gallery.

    Controls all items count property notice here it says the gallery item count is 100 but the selected item count is 500 now the reason here is the concept.

    Of Delegation when we execute a collect data operation go collect all the data from the data source it won't load all the.

    Data from my list in this collection there will be a limit purely because collection is data locally stored in your power app for that user's session and that limit if you go to your.

    App settings that is the data roll limit which is 500 so that's how this 500 came about and for the gallery item count which it says.

    100 because the items property of the gallery is a delegable query against my data source the query here is get me all the rows from the issue tracking SharePoint list.

    It's a delegable query so the gallery will load data in batches of 100 now if I scroll down to the end of the gallery the gallery will then go about loading the next set of data in.

    Memory this is optimized loading of data next I want to give the user the the ability to modify the properties of the selected items in one go now in my SharePoint list I have various types of.

    Columns I'll focus on two columns here status which is a choice column and priority which is also a choice column now in my app I will add a couple of drop- down.

    Controls the first one I'll call it DRP status the items property will be choices of my data source which is issue tracking list dot my choice column status so this drop down will load the.

    Options for the choices coming from my status column the second drop down I will rename to DRP priority the items property for this will be choices of my SharePoint list.

    Dot the column priority I've added a couple of label controls here I'll add a button the text I've set to update now on select of this.

    Button the user can in one go update these two property values for all the selected items and I would do that by using the patch function now you may be thinking that I.

    Would use use for all to Loop through all the items of the collection and go and update these items one by one for all runs in a sequential fashion it would take a performance hit in case of.

    Large number of items selected here though the collection that we are creating is being created from the items of my data source and it also has the primary key.

    Information the patch function allows us to patch a collection directly to a data source as long as the schema matches which it does in this scenario so when update is clicked the first thing I.

    Would do is I would update the data in the collection because I want to change the status value and the priority value depending upon what the user has selected in these.

    Dropdowns and to do that I will use the formula of update if my collection the condition is True Meaning go update all the items of the collection and here I would like you to.

    Go and set the following column values status is a choice column this will be set to drop down status do selected.

    Comma priority is a choice column this will be DRP priority. selected close the object complete the function now once this is done as a Next Step all I have to do is use the patch.

    Function patch to my data source The Collection that's it one single line and this will patch all the items of the collection in one go in one query to the data.

    Source and once this patch is is complete I will go ahead and use the function clear to clear the data in that collection this is also a good spot to go ahead and reset the checkbox all.

    Control let's give this a try I have two items selected I'm going to change the status of these items to closed and I will change the priority of these items to low I'll click update one.

    One go both of these items have those properties updated let's select more items as an example here I've selected 14 items I'll change the status to in.

    Progress priority High update look at the speed in one go it's patched all of that information to my data source let's try it with 500 items let's.

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continuetomake videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=Tviar3UFFLo
Previous Post Next Post