cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically add a new control

Hello!

Could you please add the functionality to dynamically (on the flow/programatically) add new controls to a Screen. This is an urgent requirement as we are trying to build Apps with custom fields. According to the Data Type of the custom field we want to be able to add the relevant control to the screen.

 

Thanks

Status: New
Comments
WPB
Level 8

Just hide/show them. I do this in many of my apps and it's fast and easy. If you wish to be able to add indefinitely, put them in a gallery and add a button to create a new record in the gallery source.

 

 

Level: Powered On

Totally agree with this idea/wish. My case, we need to create 20 forms as InfoPath alternative but if we can add dynamically controls such as Labes, Textinputs, we can easily add them programmatic way let's say using/preparing "table" containning formats of each components, within One screen and easy to maintain.

 

Definitely "hide/show" visibility control works (as well as using Gallery for sure) in some cases but if 20 forms (in my case) are completely different controls/style as same hight and width, we should create 20 screens currently and make us tired creating/maintaining them.

I hope development team will go further in this area same as new idea "reusable compornets"!

 

2019-02-27_12-45-20.jpg

Level: Powered On

Hi ,

              Do you any one having idea about how to create dynamic control using power apps?

Ex: If i am having Textbox, Assuming that will be entering 2 then,  i need to show 2 dymanic control in below (textbox,label,dropdownlist).

 

Kindly provied your input for this , if possible.

 

Thanks,

Manickam

 

WPB
Level 8

Hello!

The solution:

1) Create a Collection (oCollect with columns to store your data)

2) Display the Collection in a Gallery where you have your dynamic controls.

3) Add a button to add a record (So, you create more controls)

Level: Powered On

Hi ,

 

Could you please provide any any link for more details or any youtube video.

 

Thanks ,

Manickam

Level: Powered On

Hi WPB,

 

Thanks for quick help.

 

I am able to generate dynamic label now, but our requirement to create dynamic forms and dynamic controls on those forms on button click.

 

Thanks,

Manickam

 

 

WPB
Level 8

Dynamic Controls.gif

 

Init Collection - OnSelect: 
ClearCollect(oCollect, AddColumns(Blank(),"Button", 0, "CheckBox",0,"CheckBoxText","", "Text","","oCount",0))

Add Ctrls - OnSelect:
Patch(oCollect, Defaults(oCollect), {Button:Toggle2.Value,CheckBox:Toggle2_1.Value,CheckBoxText:TextInput2.Text,Text:TextInput2_2.Text, oCount:Count(oCollect.Button)})

Gallery4 - Items:
oCollect

For each controls in the gallery:
Visibility: Thisitiem.Button / ThisItem.CheckBox
Thisitem.text....
Level: Powered On

Hi WPB,

 

Thanks for your quick response.

 

Our requiremet is CreatDynamicControl using Power apps.PNGSample format of table.

Our Requirement - We have table format same as above.

To create dynamic controls using this table.

 

Example :->Case 123 having  form1 and dropdown columns having YES or NO.

Yes 😆 means need to create dropdown list box,

NO 😆 means not required, 

yes/no rules is applicable for other controls (label, Textbox).

Count:->DropdownCount columns having 1,2 ,3 numbers 

1 😆 means one dropdownlist box

2 😆 means two dropdownlist box

same rules is applicable for other controls (Label,Textbox).

 

Could you please suggest how to create dynamic controls  as per above ask?

 

Thanks,

Manickam

Level: Powered On

Hi WPB Team,

 

Could you please your Suggestion on this?

 

Thanks,

Manickam

WPB
Level 8

Hi Manickam,

Like i posted above, it's just a combination of ifs in the visible properties of each control. The dynamic part is made by the table part.

 

So: 

1) You create a collection from your table.

2) You create a gallery with all the controls you would need in all situations.

3) Using Thisitem, you populate the Visible property of the controls.

 

Tada!