cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Madumi
Advocate II
Advocate II

Select function syntax Select(Gallery1, 1) not working

I have a gallery galNav1 and wish to have a button (OnSelect) select the 2nd row in that gallery. I am attempting to use the following syntax (on the same screen), but powerapps keeps underlining the formula in red. Any suggestions how to correct my syntax?

 

Select(galNav1, 2)

 

Thanks so much!

9 REPLIES 9
EricLott
Resident Rockstar
Resident Rockstar

What is the use case here? I'm not sure this is possible, and there may be an easier way to accomplish this. I'll try to figure out a way to do this, though.

EricLott
Resident Rockstar
Resident Rockstar

I did find the functionality you need in the docs here

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-select

Select( Control, Row or column, Child Control )

  • Control – Required. The control to select on behalf of the user.
  • Row or column – Not required. The number of row or column (starting with 1) in a gallery control to select on behalf of the user.
  • Child Control - Not required. The child control of the control identified in the 'control' parameter to select.

but I can't seem to get it to work. I'm not sure if this has been retired without being removed from docs, or if I'm missing something. I'll keep looking.

Thx @EricLott 

Yes, I was also wondering if the functionality had somehow been retired...

The use case is that I have a gallery I'm using for navigation, based on a collection, and spread across four screens. Here's the collection:

ClearCollect(
    ColMenuItems,
    {
        id: 1,
        MenuLabel: "Projects",
        screen: Screen1
    },
    {
        id: 2,
        MenuLabel: "Operating Units",
        screen: Screen2
    },
    {
        id: 3,
        MenuLabel: "Managers",
        screen: Screen3
    },
    {
        id: 4,
        MenuLabel: "Member Agencies",
        screen: Screen4
    }
)

Is there another, or a better way in which I can for example trigger menu id: 2 to be selected when the user navigates to Screen2? I have tried using Default on the gallery, but this doesn't work after the 1st navigation away from it (default seems to become cleared, and the last gallery item which was selected, remains selected when the user navigates back to this screen).

thanks!

EricLott
Resident Rockstar
Resident Rockstar

You could use the screen's OnVisible property to do this formula:

Set(CurrentRecord,Filter(ColMenuItems,screen=App.ActiveScreen.Name))

Then use the CurrentRecord variable as your selected item.

@EricLott 

Sorry, I wasn't as clear as I could be... What I am attempting to do is have the gallery row which corresponds with the current screen selection to also be selected *within the gallery* i.e. I need a visual indication of the currently selected row so the user can see the selection eg. If(ThisItem.IsSelected,RGBA(255,255,255,1),RGBA(0, 0, 0, 1))

I guess I'm looking for the mechanism to have that row in the gallery be selected as if the user had just clicked on that row (it's a situation where, having navigated from another screen, the row is not yet selected).

thanks!

EricLott
Resident Rockstar
Resident Rockstar

Got it! So on your gallery's Items property, you'll use something like this:

AddColumns(YourDataSource,"screen",Lookup(ColMenuItems,id=[@id],screen))

Then in your gallery, you can use this according to your example above

If(ThisItem.screen=App.ActiveScreen.Name,RGBA(255,255,255,1),RGBA(0, 0, 0, 1))

 ---
If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

Thx @EricLott 

Hmmm, I'm not sure I'm quite following you on the:

AddColumns(YourDataSource,"screen",Lookup(ColMenuItems,id=[@id],screen))

(in my Gallery, my "YourDataSource" is ColMenuItems)... Powerapps doesn't seem to take the property...

Am I right thinking that your example will change the color to show which screen the user is on, but not actually select that row in the gallery? Is there a way to select that row in the gallery?

yashag2255
Dual Super User II
Dual Super User II

Hi @Madumi 

 

Can you try to set up the configuration like:

Gallery -> Default -> LookUp(ColMenuItems,screen = App.ActiveScreen)

Make sure that you apply the change on all the screens.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

@Madumi 

Exactly, there is something wrong with Select() function. 

I will submit this issue to the PowerApps Team. If there is any update, I will post back.

Sik

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,465)