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

Change dropdown values with button

I have a DropDown which has a few values. How I can change of 1st value to 2nd, 3rd and etc on click button next?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Change dropdown values with button

Hi @Yerlasdutco ,

I'm going to assume you have a good reason to be using a dropdown for this in the first place 🙂

To do this, I would give your dropdown items a numerical index - (a column of unique values you can apply simple add/subtract operations to) - then you can cycle through the items up and down the list using your buttons.  It sounds more complicated than it is 🤔

 

example: you can adapt this to your current solution

Create a button - we're going to use this to create a new collection from your current dropdown source and add an index column to it.  Set the button OnSelect: property to;

ClearCollect(collectDropDownItems, AddColumns([currentDropDownSource], "Index", 0));

UpdateIf(collectDropDownItems, Index=0, {Index: Last(SortByColumns(collectDropDownItems, "Index", Ascending)).Index + 1})

where [currentDropDownSource] is whatever source your Dropdown is currently getting it's Items from (another collection or list or wherever).
In the above, we're first creating the new collection with the added index column but setting all Index values to 0.  Then we're updating the index columns to be incremental (1,2,3,4 etc.) for each record.

Now add a dropdown and set it's Items: property to collectDropDownItems. 

Add your next and previous buttons - set the next button OnSelect: property to;

UpdateContext({currentItem:LookUp(collectDropDownItems, Index=Dropdown1.Selected.Index + 1)})

 and the previous button OnSelect: property to

UpdateContext({currentItem:LookUp(collectDropDownItems, Index=Dropdown1.Selected.Index - 1)})

 Now you have a variable that can move up and down your list using the index and the buttons relating to the currently selected dropdown item - last thing to do is bind your dropdown Default: property to the variable so it changes as your click your buttons.

Set your dropdown Default: property to;

currentItem.[dropdownfield]

where [dropdownfield] is whichever field your dropdown is displaying - for example, if your dropdown is showing the Title column, it would be 

currentItem.Title

Now you can navigate up and down your dropdown list using the buttons - you don't have to worry about setting upper and lower limits either, it will just return Blank() when it can't find an index and your dropdown will stay where it is.

Hope this helps,

RT

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Change dropdown values with button

Hi @Yerlasdutco ,

 

Hard to say - How many items in the list?  It looks like you're on 116 at that point.

Check your collection index and the sortorder just to make sure it can actually go up from there - if the previous is working, then the next should also work, assuming it's just adding 1 instead of subtracting 1.  Here's a working test app example

 

Kind regards,

RT

View solution in original post

3 REPLIES 3
Highlighted
Microsoft
Microsoft

Re: Change dropdown values with button

Hi @Yerlasdutco ,

I'm going to assume you have a good reason to be using a dropdown for this in the first place 🙂

To do this, I would give your dropdown items a numerical index - (a column of unique values you can apply simple add/subtract operations to) - then you can cycle through the items up and down the list using your buttons.  It sounds more complicated than it is 🤔

 

example: you can adapt this to your current solution

Create a button - we're going to use this to create a new collection from your current dropdown source and add an index column to it.  Set the button OnSelect: property to;

ClearCollect(collectDropDownItems, AddColumns([currentDropDownSource], "Index", 0));

UpdateIf(collectDropDownItems, Index=0, {Index: Last(SortByColumns(collectDropDownItems, "Index", Ascending)).Index + 1})

where [currentDropDownSource] is whatever source your Dropdown is currently getting it's Items from (another collection or list or wherever).
In the above, we're first creating the new collection with the added index column but setting all Index values to 0.  Then we're updating the index columns to be incremental (1,2,3,4 etc.) for each record.

Now add a dropdown and set it's Items: property to collectDropDownItems. 

Add your next and previous buttons - set the next button OnSelect: property to;

UpdateContext({currentItem:LookUp(collectDropDownItems, Index=Dropdown1.Selected.Index + 1)})

 and the previous button OnSelect: property to

UpdateContext({currentItem:LookUp(collectDropDownItems, Index=Dropdown1.Selected.Index - 1)})

 Now you have a variable that can move up and down your list using the index and the buttons relating to the currently selected dropdown item - last thing to do is bind your dropdown Default: property to the variable so it changes as your click your buttons.

Set your dropdown Default: property to;

currentItem.[dropdownfield]

where [dropdownfield] is whichever field your dropdown is displaying - for example, if your dropdown is showing the Title column, it would be 

currentItem.Title

Now you can navigate up and down your dropdown list using the buttons - you don't have to worry about setting upper and lower limits either, it will just return Blank() when it can't find an index and your dropdown will stay where it is.

Hope this helps,

RT

View solution in original post

Highlighted
Frequent Visitor

Re: Change dropdown values with button

Dear @RusselThomas 

 

I tried it. Everything works except "Next" button. 

Any ideas why?

Highlighted
Microsoft
Microsoft

Re: Change dropdown values with button

Hi @Yerlasdutco ,

 

Hard to say - How many items in the list?  It looks like you're on 116 at that point.

Check your collection index and the sortorder just to make sure it can actually go up from there - if the previous is working, then the next should also work, assuming it's just adding 1 instead of subtracting 1.  Here's a working test app example

 

Kind regards,

RT

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,181)