cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DrBread
Level: Powered On

Filtering by selected Items from listboxes inside a gallery?

So I wanted to make a dynamic way to search through a set of skills pulled from my azure sql database. The data is represented with 3 tables.

My skill table has a relation to my skill type table, and my skill type table has a relation to my categories table. Basically, a skill has a type and a types has a category.

I've created a gallery which items are categories, and each item has its own gallery which items are Skill types filtered by categoryID. The Skill Type gallery has Listboxes inside of them that displays skills filtered by SkillTypeID. All this works, and each listbox has the right skills shown inside them.

The problem is, when I try to view the selecteditems of the listboxes, I don't get a thing. The initial listbox is named ListBox5, and all other listboxes are created dynamically from it. So I try to get all the selected items SkillID with 'ListBox5.SelectedItems.SkillID ' and get nothing at all.

Is there anyway to get selecteditems from listboxes in galleries?

3 REPLIES 3
Community Support Team
Community Support Team

Re: Filtering by selected Items from listboxes inside a gallery?

Hi @DrBread,

 

Which control that you used to display the selecteditems of the ListBox?

Listbox.selecteditems would return a table, so if you would like to display it, then we need to add a Gallery control.

The formula specified with the items property of the added gallery should be:

SkillTYpeGallery.Selected.ListBox.SelectedItems

48.PNG

Gallery.selected is used to identify the SkillTypeID, once generated, the Added gallery would display the Sills record associated with the SkillTypeID.

Please post back if you have any further quesitons.

Adding some reference:

List Box control in PowerApps

Understand data forms in Microsoft PowerApps

Gallery control in PowerApps

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
DrBread
Level: Powered On

Re: Filtering by selected Items from listboxes inside a gallery?

Hi v-micsh-msft,

I am using a gallery to display the selected items. Even with the code you demonstrated, I still get nothing from the selected items. It is really strange because if I pull the skill type gallery out of the categories gallery, it works.

I think there is an issue of nesting the gallerys. Not sure why or how it is happening. I've tested it now in multiple ways, and if the galleries are nested, I can't get the the selected items from the listbox inside.

I've tried this code aswell, CategoriesGallery.Selected.TypesGallery.Selected.SkillsListBox.SelectedItems

Maybe I am missing something, or maybe I should just try to implement this in a different way, I just wanted it to be dynamic so if I add more categories or types in the future I won't have to rebuild this.

Thanks

DrBread
Level: Powered On

Re: Filtering by selected Items from listboxes inside a gallery?

I just wanted to let you know I have found a sort of work around.

Instead of displaying the selected Items directly, I decided I will create a Collection to collect what is selected on the listbox when a change happens to the listbox.

So OnChange of the SkillListBox, I did this:

If( !(SkillListBox.Selected.SkillID in CacheSearchSelected.SkillID), Collect( CacheSearchSelected, SkillListBox.Selected)); RemoveIf(CacheSearchSelected, SkillID in Filter(Filter(CacheSkills, Skill_TypeID = ThisItem.Skill_TypeID), !(SkillID in SkillListBox.SelectedItems.SkillID)).SkillID)

 

SkillListBox is my listboxes
CacheSearchSelected is my Collection of selected items
CacheSkills is all of the skills
ThisItem is a skill type gallery item

I can tell the formula is a mess but it works, Ill try to explain it

First thing I check is if the selected skills are not already in the CacheSearchSelected collection and if not, add them. 

Next thing I need to do is remove skills from the CacheSearchSelected collection when someone removes a selected item, In order to know what to remove, I had to first get filter the list of skills that  are currently in the list box, and then filter out the selected items of that list box. This leaves me with a list of only the skills that aren't selected for that list box, and I can remove those skills from my CacheSearchSelected collection.

Anyway, thats how I worked around it, I'd rather not have to do all that though 😛

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 102 members 4,350 guests
Please welcome our newest community members: