cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VenuRebbala
New Member

Combobox not displaying DefaultSelectedItems

I have a Datacard in the EditForm with default value as "Car,Bus".

I have placed a Multi select Combo box within the Data card and assigned items property to a collection of 3 columns: 

 

VenuRebbala_0-1625209492898.png

 

IDFieldIDFieldName
1102Car
2104Bus
3109Bicycle

 

The default value of the data card is "Car,Bus". Now, I am using the below formula in the DefaultSelectedItems property of the Combo box to select the items by default.

 

DefaultSelectedItems:  

 

 

ForAll(Split(Parent.Default,","), Lookup(colTest, FieldName = Result))

 

 

 

Now the issue is that the combo box is not displaying the selected items visually. However, I am able to retrieve the selected items from the combo box into a text box.

 

Combobox1:

VenuRebbala_1-1625209897023.png

Textbox:

 

 

Default = Concat(Combobox1.SelectedItems, FieldName & ":" & FieldID)

 

 

VenuRebbala_2-1625210244963.jpeg

Please help me to select the items in the combo box based on the default value of the datacard.

 

10 REPLIES 10
JamesYumnam
Resolver III
Resolver III

hi @VenuRebbala  Leave DefaultSelectedItems property empty only. let me know if this helps.

But that would not help in selecting the DefaultSelectedItems.

I would like to select the items "Car,Bus" in the combobox by default .

 

JamesYumnam
Resolver III
Resolver III

Assuming colTest is your datasource, why not keep the DefaultSelectedItems = colTest  only. this will select all your records and will keep on changing as you change your selections from the dropdown.

I do not want all the records to be selected by default.

 

I want only those records to be selected which are already there in the data card.

 

I have reframed the question to make it more understandable

VenuR
Regular Visitor

Please can anyone suggest/help me to resolve the above problem?

JamesYumnam
Resolver III
Resolver III

Hi @VenuR  @VenuRebbala 

 

in the OnVisible property of your screen where your Edit form is present, create a new collection which will store the values from the datacard. Code below:

Collect(colDatacardvalues,
    {
        FieldName:DataCardValue6.Text
    },
    {
        FieldName:DataCardValue3.Text
    }
)

  

In your dropdown, make the following changes:

In the DefaultSelectedItems property, add this code:

colDatacardvalues.FieldName

Set the DataSource property to coltest collection.

Set the Items property to coltest.FieldName

 

This should give a hint of what you are trying to achieve.

Please note that there is no validation being done here as to whether the values in the datacards are present in collection colTest which is used as the datasource of the dropdown. So if any values which are displayed in the datacards, are not present in the dropdown items, you will still able to see them in the default selected items of the dropdown.

Yes, I could select all the delimited values of the datacard without validation using the formula 

DefaultSelectedItems = ForAll(Split(Parent.Default,","), {FieldName : Result})

 

However, I need validation, which is very important in my case. 

JamesYumnam
Resolver III
Resolver III

Hi @VenuR 

 

I have updated the code for OnVisible property of the screen as shown below and hope this helps you. This may not be a very good workaround but for now, this will solve your issue and you can do the fine tuning later.

 

If(DataCardValue6.Text in coltest.FieldName,
    If(DataCardValue3.Text in coltest.FieldName,
        ClearCollect(colDatacardvalues,{FieldName:DataCardValue3.Text},{FieldName:DataCardValue6.Text}),
        ClearCollect(colDatacardvalues,{FieldName:DataCardValue6.Text})));

 

Thanks,

James

Hi @JamesYumnam 

 

What are DataCardValues 3 & 6?

 

I could do partial validation using below formula, however, as you mentioned, this doesn't exactly match.

DefaultSelectedItems = Filter(colTest, FieldName in Split(Parent.Default,","))

 

For example: Data card value is "car" and colTEst has FieldNames "car, car1, car2, bus, bicycle etc." Then with the above formula, all the fieldnames which has "car" text would be selected.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,524)