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?
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.
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 😛