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

Cancel Button Selection In Gallery and return to previous selection

Hello All,

 

New to powerapps so please bare with me.

 

I have an Input Screen as below:

InputScreen.PNG

 

The the left is a gallery with sites as buttons, and to the right is a static gallery ( the same list of equipment regardless of what area is selected).

 

We have created a pop up message as suggested here

 

We have wired up to show up in the following scenario:

 

If a user inputs quantities, does not press submit and then selects another area the pop up below will be displayed:

 

PopUp.PNG

 

If they choose continue it clears the text boxes and continues to their next selection. I have this feature working.

 

The issue I am having is with the cancel button.

 

If a user selects cancel I want the following to happen:

1) Do Not clear text boxes - I have this working fine.

2) Revert the previous gallery button selection - This I can't work out.

 

E.g. User starts in Area C1 inputs values BUT does not submit. Instead they choose the area C2. The popup will be displayed and the user chooses to cancel. When they choose cancel, the gallery selection should go back to C1. Currently it just continues to C2  (indicated by the label just to the right of the area buttons)as below:

 

cancelleResult.PNG

 

Is there a way to achieve what I want here?

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi  @DilshanSS ,

 

You can use the following code to generate a SelectHistory Collection to keep track of the number of rows you select each time, put it to Button.OnSelect in AreaGallery.

Collect(SelectHistory,Len(First(Split(Concat(ForAll(AreaGallery.AllItems, If(Area = AreaGallery.Selected.Area, 1, 0)), Value & ""), "1")).Result)+1)

Put the following code on CancelButton.OnSelect property to select the number of rows selected the penultimate time.

Select(AreaGallery,First(LastN(SelectHistory,2)).Value,AreaButton);Clear(SelectHistory)

Test Result:

GIF_55.gif

Hope this helps,

Sik

View solution in original post

7 REPLIES 7
Carsten_Growth
Power Apps
Power Apps

Try something like Select(Gallery1; 1; ChildControl1)

where Gallery1 is your gallery showing the buttons, 1 is the first item(row) and ChildControl1 should be your Button control (name) inside your Gallery1

Hey @Carsten_Growth  thank you for the quick reply. This is a lot closer to what I want.

To the OnSelect property of my PopUp window cancel button I added:

Select(Area,1,Areas). This gets me back to the first item in the gallery. Is there a way the define the last selected instead of hard coding 1?

If you store an Item ID within your Button gallery, you could use it inside a variable with Set(selectedBtn, ThisItem.ID). That way you do have a dynamic value that you can use instead of the hardcoded "1"

Hi @Carsten_Growth  thanks again for you're reply. 

 

I have a dimension table: Location (LocationKey, Area, Site)

 

My gallery: Area

 

has buttons in it and the text property of the buttons are populated by: ThisItem.Area

 

For my popUp Cancel button I have added: Select(Area,LocationKey,Areas)

 

When I run the app cancel just stays on the current selection as if it is not reading the locationKey.

 

I get the below error on my cancel button:

the row or columns passed to the select function is outside the bounds of the gallery items

 

am I missing something here?

 

Do I somehow need an ID generated for each item on the gallery?

 

Thanks again


 

has buttons in it and the text property of the buttons are populated by: ThisItem.Area

 

So does LocationKey contain information, such as 1, 2, 3 ?

If so you can use LocationKey as your indicator. But you should set a variable by click on the Button. Something like Set(mySelectedItem, ThisItem.LocationKey) which would put mySelectedItem to either 1, 2, or 3 and that could be used then in your Select statement as dynamic variable


 

Hi @Carsten_Growth 

 

that is right, LocationKey has integer values (1,2,3,....30)

 

the OnSelect of my Area button has the below:

UpdateContext({AreaNameChosen: ThisItem.Area});
UpdateContext({LocationKey: ThisItem.LocationKey});
UpdateContext({AreaSelected: true});
If(And(SubmitSelected = false, AreaSelected = true),UpdateContext({ShowPopUp:true}),UpdateContext({resettext: !resettext}));

 

I just get the same error: "Row or Column passed to the select function is outside the bounds of the gallery items." Have tried searching this error but not getting much luck. Is there a conversion required. the data type in the sql table is already integer?

 

Thanks

 

v-siky-msft
Community Support
Community Support

Hi  @DilshanSS ,

 

You can use the following code to generate a SelectHistory Collection to keep track of the number of rows you select each time, put it to Button.OnSelect in AreaGallery.

Collect(SelectHistory,Len(First(Split(Concat(ForAll(AreaGallery.AllItems, If(Area = AreaGallery.Selected.Area, 1, 0)), Value & ""), "1")).Result)+1)

Put the following code on CancelButton.OnSelect property to select the number of rows selected the penultimate time.

Select(AreaGallery,First(LastN(SelectHistory,2)).Value,AreaButton);Clear(SelectHistory)

Test Result:

GIF_55.gif

Hope this helps,

Sik

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

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