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

Patch A Gallery's Source Collection Using Combo Box Populated by the Same Collection

I have the following collection:

Collect(
    col_products,
    {
        index: Last(col_products).index + 1,
        product:"",
        unit: "",
        qty:"",
        start:"",
        end:"",
        count:"",
        month:0,
        start_date:Today(),
        end_date:Today(),
        mt:"",
        criteria: ""
    }
    );

The item property of my gallery is set to the collection above.

My first control in the gallery is a combo box. This control has the following for its OnChange property:

Patch(col_products, ThisItem ,{product: Self.Selected.spec})

spec is effectively the name of the product and is what they select from the combo box.

 

The DefaultSelectedItems property of this control is this:

LookUp(Products, bat_spec = ThisItem.product)

 

The first time you select an item from the combo box, the combo box blinks, and the selected item shows up. If I check the col-products collection, it shows the patch has worked properly. However, if I attempt to change the selection, things get a little weird.

Whatever change I make has to be made twice. For instance, if I click to remove the selected item, I have to do so twice. If I click a different product (multi-select is not enabled) the product won't change unless I click the new item twice. Even stranger, if I select product 1 for my initial value, then click product 2, nothing happens. If I click products 3 through 7, still, nothing happens. Then, if I click any of the previously clicked items, it will change to them. I can even change between these previously selected items with a single click.

 

Any ideas on how to resolve this would be very very welcome. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
cleve
Helper I
Helper I

Painful lesson here: don't use comboboxes in this scenario.

Power Apps doesn't get along with its own comboboxes, so they can't be used as easily as other controls. For instance, if you put a Patch or Update expression on the OnChange property of a combobox, you will get random results like these.

The process goes something like this:

1) The collection is initialized

2) The gallery then populates and loads the combobox(es)

3) The default property is then applied to the combobox WHICH REGISTERS AS A CHANGE.

 

This then triggers the OnChange and can even create an infinite loop.

 

 

View solution in original post

1 REPLY 1
cleve
Helper I
Helper I

Painful lesson here: don't use comboboxes in this scenario.

Power Apps doesn't get along with its own comboboxes, so they can't be used as easily as other controls. For instance, if you put a Patch or Update expression on the OnChange property of a combobox, you will get random results like these.

The process goes something like this:

1) The collection is initialized

2) The gallery then populates and loads the combobox(es)

3) The default property is then applied to the combobox WHICH REGISTERS AS A CHANGE.

 

This then triggers the OnChange and can even create an infinite loop.

 

 

View solution in original post

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,454)