cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lairpr
Helper I
Helper I

Repeat section in Gallery with comboboxes

Hi,

 

I am working on an App that uses a repeat section in a gallery. On the gallery, I have several combo boxes. Two of those combo boxes need to be hidden if the first combo box contains "_someword_". When a new item is added the other two combo boxes get set back to be hidden. 

Combo 1

Combo 2 - Set to be hidden. If Combo 1 contains "_someword_" then is set to visible.

Combo 3- Set to be hidden. If Combo 1 contains "_someword_" then is set to visible.

 

I am trying to keep both combo boxes visible when a new line is added to the collection. 

 

Any ideas on how I can accomplish this?

 

Thank you.

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @lairpr ,

You should just need on the Visible of the combo boxes

ComboBox1.Selected.Value = "_someword_"

Note Value may be different depending on the Items of the Combo Box

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi Warren,

Thank you for replying to my message. I hope you are doing well. 

On my dropdown1(main) I have as items ["","_sometext_","_someothertext_"]

And have set the visible property of ComboBox1 to If("_sometext_" in Dropdown1.Selected.Value,true, false).

When I click on the Save button to add a new row with my dropdown and combo box. The value on the ComboBox for Visible is back to hidden. And ComboBox is no more visible on the first line. Even if I keep adding rows, it will not be visible.  Not sure why, I even created a new collection and added a new gallery with new controls. Any idea what can be setting the visible property back to false? 

Here is what I have:

ClearCollect(
TestCollection,
{
C_ThisDropdown:"",
C_ThisCombo:""
}
);

Gallery Items:TestCollection

Patch on Save Button:
Patch(
TestCollection,
ThisItem,
{

C_ThisDropdown: Dropdown1.Selected.Value,
C_ThisCombo: ComboBox1.Selected.Value
}
);
Collect(
TestCollection,
{
C_ThisDropdown: "",
C_ThisCombo: ""
}
);

 

 

Hi @lairpr ,

See below

cbVisibleGallery.gif

Collection at Screen OnVisible is the same as yours

ClearCollect(
   TestCollection,
   {
      C_ThisDropdown: "",
      C_ThisCombo: ""
   }
)

Save icon OnSelect is (I just have different control names)

Patch(
   TestCollection,
   ThisItem,
   {
      C_ThisDropdown: ddMain.Selected.Value,
      C_ThisCombo: cbMain.Selected.Value
   }
);
Collect(
   TestCollection,
   {
      C_ThisDropdown: "",
      C_ThisCombo: ""
   }
);

Visible on the Combo Box (as I posted in my initial response)

ddMain.Selected.Value = "_sometext_"

Default of Drop-down

ThisItem.C_ThisDropdown

Combo Box DefaultSelectedItems

{Value:ThisItem.C_ThisCombo}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

I forgot to mention that "_sometext_" is not a value in the Combobox. "_sometext_",  is part of a text in the selected item from Dropdown1. Dropdown1.Selected."This_is_sometext_in_this_item". Some of the items in Dropdown1 could contain "_sometext_" in the name. 

This is what I have:

If("_sometext_" in Dropdown1.Selected.Description, true, false)

@lairpr ,

Sorry you have lost me - you said the Items of Dropdown1 was

[
  "",
  "_sometext_",
  "_someothertext_"
]

Could you please post actual code so as to not confuse the matter. What are the actual Items of Dropdown1 as I see the output is Description, not Value. Also what do you mean by Some of the items in Dropdown1 could contain "_sometext_" in the name - if it is a dropdown, the user can only choose the options, so it will either match the item or not.

However disregarding this if you are looking for the Visible property, it just needs to be

"_sometext_" in Dropdown1.Selected.Description

You do not need the If(), true or false.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

The values or items displayed in Combobox1 are coming from SQL table. The table has many items that contain "sometext" in the name. Example: Combobox1 item name is Description, Combobox1.Selected.Description. The "Description" value can have X amount of items that some of those items can contain "sometext" in the description name. 

Combobox1 Items

["This_Item_Has_sometext_In_The_Description_Text", "This_Item_Has_Another Name_In_The_Description_Text", "This_Second_Item_Has_sometext_In_The_Description_Text]". 

DefaultSeelctedItems in Combobox1: {Value:ThisItem.C_Description}. I also tried using, [ThisItem.C_Description].Value

In the Combox or Dropdown that I am trying to show the Visible property has: 

If("_sometext_" in Combobox1.Selected.Description, true, false).

I am using  "in" and not "=" because I am looking in the item value to check if it has "_sometext_" or "sometext". 

The Combobox or dropdown that I am setting the Visible property gets set back to hidden when a new item is added(Patch) in the Gallery. The Gallery is like a repeat section in InfoPath.  

Basically, that is where the problem is. When a new Item is added(Patch) in the Gallery the Combobox2 or Dropdown won't stay visible in the first item that was added in the Gallery. 

 

Hi @lairpr ,

A bit of confusion naming your fields and controls dropdown and combo when they are both combo boxes and also you not mentioning this is multi-select (which a dropdown cannot do) , but the Visible of your second control needs to be something like

 "_sometext_" in Dropdown1.SelectedItems.Description

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

The names are just an example, those are not the real names. I have tried with Comboboxes and Dropdowns and still, they get set back to false(hidden) when patch. I also tried your last suggestion and didn't work. This was something I had working before. I'll figure out something.

Thank you!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,022)