cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
myka
Frequent Visitor

Create dropdown to filter results in gallery

I am working on a power app for tracking LAB details and I have a gallery
that is populated from a SharePoint list. I'm currently filtering the values in the gallery ("items" property) to the record owner.
If I'm the owner of LAB_1, LAB_2, LAB_3, I can only see the records that belong to those LABs. I want to add the ability for an owner
to use a drop down and further limit results - So, when the gallery populates, it shows all the LAB records I own, I then want the ability
to select an item from a dropdown to show only records related to that specific LAB value. From the example above, my drop-down would
contain "LAB_1, "LAB_2", and "LAB_3". If I select "LAB_3" only records relating to LAB_3 are shown.

I thought the best way to implement the dropdown filter was to associate it with a different SharePoint list that contains the names of all
LABs and the corresponding owner. MY ISSUE: The problem is that when the gallery loads, it loads the LAB records that I own, but it also applies whichever
dropdown filter that is at the top of the list, so I'm not seeing all of the records I own when the gallery loads. I assume part of the issue
is that there isn't an "All" value in the LABS_NAME list.


--applied to items for the gallery
If(
labRole = "POC",
Filter(
'LABs Details',
StartsWith(
Name1,
TxtSearch_9.Text
) || StartsWith(
Owner.DisplayName,
TxtSearch_9.Text
)
),
labRole = "Monitor",
Filter(
'LABs Details',
StartsWith(
Name1,
TxtSearch_9.Text
) || StartsWith(
Owner.DisplayName,
TxtSearch_9.Text
)
),
labRole = "Owner",
Filter(
'LABs Details',
StartsWith(Owner.Email,varCurrentUser.Email),
(StartsWith(
Name1,
TxtSearch_9.Text
) || StartsWith(
Owner.DisplayName,
TxtSearch_9.Text
)) && (LAB_Name = DrpLABNames_x.Selected.'LAB NAME' || DrpLABNames_x.Selected.'LAB NAME' = Blank())
),
Filter(
'LABs Details',
(StartsWith(
Name1,
TxtSearch_9.Text
) || StartsWith(
Owner.DisplayName,
TxtSearch_9.Text
)) && (LAB_Name = DrpLABNames_x.Selected.'LAB NAME' || DrpLABNames_x.Selected.'LAB NAME' = Blank())
)
)

 



Tried this, but it didn't work - the values displayed, but nothing happened when I selected a value - applied to items property of the dropdown
Ungroup(
    Table(
        {LABMenuOptions: Table({'LAB NAME': Blank()})},
        If(
          labRole = "Owner" || labRole = "POC",
         {LABMenuOptions: Filter('LAB_NAMES', StartsWith('LAB OWNER'.Email,varUserEmail)).'LAB NAME'},
         {LABMenuOptions: 'LAB_NAMES'.'LAB NAME'}
      )
),
"LABMenuOptions"
)


This works, but it results in the issue I'm trying to overcome - it applies whatever is the first value to the filter in the gallery.

I'm applying it to the dropdown, items propetry
        If(
            dalRole = "Owner",
            Filter(
                DAL_NAMES,
                StartsWith(
                   'DAL OWNER'.Email,
                   varUserEmail
                )
            ),
           DAL_NAMES.'DAL NAME'
)

1 ACCEPTED SOLUTION

Accepted Solutions
Scott_Parker
Responsive Resident
Responsive Resident

Change the dropdown's AllowEmptySelection property to true and set the default value to Blank()

View solution in original post

4 REPLIES 4
Scott_Parker
Responsive Resident
Responsive Resident

Change the dropdown's AllowEmptySelection property to true and set the default value to Blank()

That seems to work. I have an additional issue/question related to that. I scroll down my list and I haven't selected anything from the drop-down. If I'm midway or so down my list and I select a value from the drop down, it takes me to the correct choice, but it doesn't start me at the top of the choices. So, say I scroll have way down my list and I'm into the LAB_3 values, If i click the drop-down and select LAB_1, it puts me someone in the middle of the LAB_1 values and not at the top. Anyway to overcome that? 

That seems to work. I have an additional issue/question related to that. I scroll down my list and I haven't selected anything from the drop-down. If I'm midway or so down my list and I select a value from the drop down, it takes me to the correct choice, but it doesn't start me at the top of the choices. So, say I scroll have way down my list and I'm into the LAB_3 values, If i click the drop-down and select LAB_1, it puts me someone in the middle of the LAB_1 values and not at the top. Anyway to overcome that? 

Scott_Parker
Responsive Resident
Responsive Resident

SetFocus can't be used on controls inside a gallery. But, the Gallery Default property can set which item will appear at the top. This answer has a good explanation: Solved: Force Gallery to Scroll to First Record (Back to T... - Power Platform Community (microsoft....

 

You could do something similar. There isn't a way to get or set the position of the scrollbar directly.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,826)