How to Select MULTIPLE Items in Power Apps Gallery & PATCH

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
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 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 [Music] 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 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 change the status of these items to open priority medium I'm trying this live 500 items are being patched I'm not going to edit this part of the video so this will give you a good indication of the speed there you go my first 500 items have the status updated to open and priority is medium and to confirm if you look at the backend data source all those changes are in play I've added the option here to filter based on priority this is what my filter condition looks like now this items property copy it checkbox all on check where you're collecting data in the collection write that same formula here make sure that on change of your filters in my case on change of my drop- down filter I would like to go ahead and clear the data in my collection show me all the high priority items let me go ahead and select these five I'm going to change the priority to low the status I'll set to closed hit update there we go those five items have been updated and notice if I have items selected and if I change my filtering it's all cleared again so I can go and start selecting if you enjoyed this video then do like comment and subscribe to my YouTube channel and thank you so much for watching
Info
Channel: Reza Dorrani
Views: 18,080
Rating: undefined out of 5
Keywords: powerapps multi select, reza dorrani, powerapps patch gallery, powerapps patch gallery selected items, power apps, power apps select multiple items in gallery, powerapps, powerapps tutorial, microsoft powerapps, powerapps checkbox gallery, powerapps checkbox select all, powerapps gallery checkbox multiple selection, powerapps patch multiple records, power apps patch gallery all items, check all, patch, powerapps checkbox in gallery, learn powerapps, power apps beginner, how to
Id: Tviar3UFFLo
Channel Id: undefined
Length: 14min 43sec (883 seconds)
Published: Mon Jan 22 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.