0
votes

I am building a powerapp where I have a radiobutton list , if any item of the radiobuttonlist is selected then dropdown will populate accordingly else it should show a default value such as Select a Product. I want to use if conditon for Items Property of dropdowncontrol this e.g.

Items = if(IsBlank(Radio.Selected.Value),DropDown.Selected.Value = "Select Product", Filter(ProductDemands, ProductValue = Radio.Selected.Value))


where ProductDemands is name of entity ProducValue is column name

I am unable to acheive the same. I am getting syntax errors and warnings for the same.

1

1 Answers

0
votes

There are a few ways you can solve this. One is to disable the dropdown whenever there is no selection in the radio buttons - this way the user will know that they have to do something with it. You can do it by setting the DisplayMode property in your dropdown control to this:

If(IsBlank(Radio1.Selected.Value), DisplayMode.Disabled, DisplayMode.Edit)

Another option is to have a couple of controls, the dropdown and a label (with a message "please select a value") positioned on top of each other. Then you can toggle the visibility of the controls depending on whether there is a selection in the radio buttons or not.

Yet another option is to define a table with the same schema as the collection you want to display in the dropdown that has only 1 value (with something like "Select Product", and use an If condition in the Items property to select between that collection and your filtered one. One way to do that is to initialize such collection when the screen is loaded (in the OnVisible property):

ClearCollect(defaultDemands, Defaults(Demands));
Clear(defaultDemands);
Patch(defaultDemands, Defaults(Demands), {Name:"Select Product"})

The first part of the expression creates a collection with an "empty" version of the demand (thus copying the schema to the new collection). The second clears it, and the third one adds a new item where the name is what you want displayed. Then in the Items property of the dropdown you can choose between the two collections depending on the state of the radio selection:

If(
    IsBlank(Radio1.Selected.Value),
    defaultDemands,
    Filter(ProductDemands, ProductValue = Radio1.Selected.Value))