Hello. I am trying to use a dropdown box to create a sort of pagination for my app. However I am having an issue where it is navigating to the first screen which should only be triggered by the first condition, regardless of what condition is met.
Here is the if statement in the 'OnChange' property of the drop down box. (The box is titled Pagination)
If(Pagination.Selected.Value = "1", Navigate(scrAddNomCore, ScreenTransition.None), Pagination.Selected.Value = "2", Navigate(scrAddNomKeyInfo, ScreenTransition.None),Pagination.Selected.Value = "3", Navigate(scrAddNomDetails, ScreenTransition.None), Pagination.Selected.Value = "4", Navigate(scrAddNomCitations, ScreenTransition.None), Pagination.Selected.Value = "5", Navigate(scrAddNomRanking, ScreenTransition.None), Pagination.Selected.Value = "6", Navigate(scrAddNomProposer, ScreenTransition.None), Pagination.Selected.Value = "7", Navigate(scrAddNomValidation, ScreenTransition.None), Pagination.Selected.Value = "7", Navigate(scrAddNomValidation, ScreenTransition.None), Pagination.Selected.Value = "8", Navigate(scrAddNomAttachments, ScreenTransition.None), false)
The Items property of the drop down box is: [1,2,3,4,5,6,7,8]
It is navigating to the first screen regardless of what value is changed.
Solved! Go to Solution.
@David998721good suggestions above. I personally like the gallery based navigation, but if dropdown is the thing, that's fine too.
Also, you might want to consider two other things.
1) Use a Switch statement rather than a bunch of If statements this would be a little cleaner to troubleshoot.
Switch(Pagination.Selected.Value 1, Navigate(scrAddNomCore, ScreenTransition.None), 2, Navigate(scrAddNomKeyInfo, ScreenTransition.None), 3, Navigate(scrAddNomDetails, ScreenTransition.None), 4, Navigate(scrAddNomCitations, ScreenTransition.None), 5, Navigate(scrAddNomRanking, ScreenTransition.None), 6, Navigate(scrAddNomProposer, ScreenTransition.None), 7, Navigate(scrAddNomValidation, ScreenTransition.None), 8, Navigate(scrAddNomAttachments, ScreenTransition.None))
2) - since you are going to probably use this on every page, you will be faced with copy and past and then, if you need changes...go fix all the places. This can be prone to error.
You might want to check out this posting on how to avoid that in your Apps.
Hope this all helps.
Hello!
Firstly have you considered using a gallery with data source [1,2,3,4,5,6,7,8], and a label with ThisItem.Value that way you can have the numbers display along the top like page numbers that users are used to rather than a dropdown:
Then you have your Onselect set a variable, maybe called ChosenPage (So that it's not reliant on the gallery on that particular page for it's value)
And then expand your onselect formula for the pages:
I've attached the POC app as well,
The principle for Dropdowns is the same - I would have it set a variable that is used to navigate rather than relying on the .selected between pages.
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hi @David998721
Try putting brackets around Pagination.Selected.Value = "1" and all of the other ones.
I have had this problem before with not putting brackets around everything.
Regards
Nigel
You should definitely not have to bracket the logic unless it explicitly requires brackets. It's nice to compartmentalize them that way, but it's not a requirement.
So what I would hazard a guess is happening in your App currently is that on the other pages you have a control with a different name - so when you then click that control, it is navigating to page 1, as your control called Pagination on page 1 still has a selected value of 1.
This is why I'd suggest using variables - you can't refer to a control on another page when you are changing a control on a separate page.
Also you have a 7 check twice in your formula 🙂
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
@David998721good suggestions above. I personally like the gallery based navigation, but if dropdown is the thing, that's fine too.
Also, you might want to consider two other things.
1) Use a Switch statement rather than a bunch of If statements this would be a little cleaner to troubleshoot.
Switch(Pagination.Selected.Value 1, Navigate(scrAddNomCore, ScreenTransition.None), 2, Navigate(scrAddNomKeyInfo, ScreenTransition.None), 3, Navigate(scrAddNomDetails, ScreenTransition.None), 4, Navigate(scrAddNomCitations, ScreenTransition.None), 5, Navigate(scrAddNomRanking, ScreenTransition.None), 6, Navigate(scrAddNomProposer, ScreenTransition.None), 7, Navigate(scrAddNomValidation, ScreenTransition.None), 8, Navigate(scrAddNomAttachments, ScreenTransition.None))
2) - since you are going to probably use this on every page, you will be faced with copy and past and then, if you need changes...go fix all the places. This can be prone to error.
You might want to check out this posting on how to avoid that in your Apps.
Hope this all helps.
ooOooooH! I like it! Toggle-based actioning of any stored code - that will be really useful, thanks for the idea 🙂
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hi @David998721 ,
Could you please share a bit more about your issue?
Do you mean that the first condition in your If function always be true, regardless of other conditions are met?
I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try to modify your formula as below:
If(
Pagination.Selected.Value = "1",
Navigate(scrAddNomCore, ScreenTransition.None),
Pagination.Selected.Value = "2",
Navigate(scrAddNomKeyInfo, ScreenTransition.None),
Pagination.Selected.Value = "3",
Navigate(scrAddNomDetails, ScreenTransition.None),
Pagination.Selected.Value = "4",
Navigate(scrAddNomCitations, ScreenTransition.None),
Pagination.Selected.Value = "5",
Navigate(scrAddNomRanking, ScreenTransition.None),
Pagination.Selected.Value = "6",
Navigate(scrAddNomProposer, ScreenTransition.None),
Pagination.Selected.Value = "7",
Navigate(scrAddNomValidation, ScreenTransition.None),
Pagination.Selected.Value = "8",
Navigate(scrAddNomAttachments, ScreenTransition.None)
)
In addition, I also agree with @RandyHayes 's thought almost. You could also consider take a try to achieve your needs using Switch function. Please take a try with the following formula:
Switch( Pagination.Selected.Value, "1", Navigate(scrAddNomCore, ScreenTransition.None), "2", Navigate(scrAddNomKeyInfo, ScreenTransition.None), "3", Navigate(scrAddNomDetails, ScreenTransition.None), ... "8", Navigate(scrAddNomAttachments, ScreenTransition.None) )
Best regards,
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
279 | |
236 | |
84 | |
37 | |
35 |
User | Count |
---|---|
356 | |
240 | |
130 | |
71 | |
50 |