Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Add rows to gallery

(0) ShareShare
ReportReport
Posted on by 559

Hi All,

I have a gallery where a check box and combo box is there. When check box is selected that respective value loads in the Combo box. For Ex. (If the check box value is design then combo box value has 3 items and  If the check box value is development then combo box value has 1 items). 

When + icon is clicked I want to load rows in gallery based on the check box selected and the items in the combo box. For Eg. (if check box value selected value is design & development  then the combo box will be having total of 4 values. So 4 rows must be added in the gallery). 

The code now written in the + icon is:

Collect(colFinalPhase,Patch, Patch(varNewPhaserecord,{ID: vartest, 'Project Name': prjnames_3.Selected.ProjectName}));

I need to load the rows in this gallery which has collection name as colFinalPhase which is above. 

This vartest is a set variable to collect the number of checkbox collected in the gallery.

Set(vartest, CountRows(Filter(Gallery2.AllItems,Checkbox2.Value = true)));

Any idea/suggestion how this can be implemented.

Categories:
  • Sri Profile Picture
    559 on at
    Re: Add rows to gallery

    @v-mengmli-msft

    whatever code I have given in the checkbox I have attached in the screenshot. The code in the Add row icon is

    ForAll(ComboBox6.SelectedItems As C,Collect(colFinalPhase,{Phase:Title2.Text,'Work product':Table(C)}));

    In the colFinalPhase gallery the Phase and Work Product dropdown Items are attached in screenshot.

    This Table C where should I give it?

  • v-mengmli-msft Profile Picture
    on at
    Re: Add rows to gallery

    Hi @Uthhra ,

     

    Could you please show me the code in your check box now and the Items of your Combo box and dropdown?

     

    Best regards,

    Rimmon Li

  • Sri Profile Picture
    559 on at
    Re: Add rows to gallery

    @v-mengmli-msft 

    Yeah Phase and Work Product in colFinalPhase gallery are dropdown. When checkbox is selected Phase is getting displayed but the Combo box values are not getting displayed in the colFinalPhase gallery when row is added.

  • v-mengmli-msft Profile Picture
    on at
    Re: Add rows to gallery

    Hi @Uthhra ,

     

    Are controls in Phase and Work product dropdown? If you want to add rows when the check box is selected, please try this:

    I assuming they are dropdown.

    Set the OnCheck of check box:

    ForAll(ComboBox.SelectedItems As C,Collect(colFinalPhase,{Phase:Checkbox6.Text,'Work product':Table(C)}))

    The result of my test:

    vmengmlimsft_1-1696581061497.png

     

    After selecting the "4".

    vmengmlimsft_2-1696581081348.png

     

     

    Hope this helps you!

    -----------------------------------------------------------------------------------------------------------------------------------

    If my answer solves your problem, please accept it as a solution to help more people stuck on the same problem find it.

     

    Best regards,

    Rimmon Li

  • Sri Profile Picture
    559 on at
    Re: Add rows to gallery

    @v-mengmli-msft 

    In the above checkbox gallery which ever check box is selected that respective checkbox and combo box items must be added to the below gallery where there are two columns called Phase and Work product. When the row is added these details must also be added to the below colFinalPhase gallery.

    The check box gallery gets the values from different list and the items of the gallery is 

    Distinct(Phasenames,Phase)

  • v-mengmli-msft Profile Picture
    on at
    Re: Add rows to gallery

    Hi @Uthhra ,

     

    What does "display" mean? Do you want to use a function like Patch to save Combo box's options to a column in colFinalPhase collection?

     

    Best regards,

    Rimmon Li

  • Sri Profile Picture
    559 on at
    Re: Add rows to gallery

    @v-mengmli-msft 

    It is working now. But whatever is selected in the checkbox gallery. How to display the values in the colFinalPhase gallery. For Ex. The value Onboarding must display in the Phase column of the colFinalPhase and combo box selected items must display on the Work Product column in colFinalPhase. Is there a way to do it?

  • v-mengmli-msft Profile Picture
    on at
    Re: Add rows to gallery

    Hi @Uthhra ,

     

    Set is a behavior function, you can't put it on the Items property, you should put it on a property like OnSelect, and the property that can put the behavior function is usually on the button, such as button, check box, etc.

     

    Hope this helps you!

    -----------------------------------------------------------------------------------------------------------------------------------

    If my answer solves your problem, please accept it as a solution to help more people stuck on the same problem find it.

     

    Best regards,

    Rimmon Li

     

  • Sri Profile Picture
    559 on at
    Re: Add rows to gallery

    @v-mengmli-msft 

    If I use Set variable in Items of combo box. I'm getting an error, "Behavior function in a non-behavior property. You can't use this property to change values elsewhere in the app".

  • Verified answer
    v-mengmli-msft Profile Picture
    on at
    Re: Add rows to gallery

    Hi @Uthhra ,

     

    Do you want to create this number of rows into the collection after getting the total number of options for Combo box with a value of true checkbox in the gallery? Please try this:

    1)Set the variable to get total number of combo box Items:

    Set(contR,0);

    The property of check box in gallery:

    OnCheck:Set(contR,Sum(CountRows(ComboBox.SelectedItems),contR));
    OnUncheck:If(contR>0,Set(contR,contR-CountRows(ComboBox.SelectedItems)))

    2)The property of button:

    ForAll(Sequence(contR), Collect(colFinalPhase,{ID:expectedValue1,'Project Name':expectedValue2}))

    vmengmlimsft_0-1696574553975.png

     

     

    Hope this helps you!

    -----------------------------------------------------------------------------------------------------------------------------------

    If my answer solves your problem, please accept it as a solution to help more people stuck on the same problem find it.

     

    Best regards,

    Rimmon Li

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,631 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,991 Most Valuable Professional

Leaderboard