Component: add it programmatically?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Is there a way to add components programmatically to a flexcontainer?

Something like: formName.flexcontainer.add(component)???

Hi @Emewson Pvwkew​ ,

In Kony Reference Architecture : this.view.add(component).

In Free Form JavaScript : formName.flexcontainer.add(component).

Thanks

hi, thanx! so add also works for components.

Do you know if it needs to be: formName.flexcontainer.add(namespace.name) or just name?

Hi @Emewson Pvwkew​,

Sample Code using Tabs component:

var tabs = new com.konymp.tabstextline(

{

"clipBounds":true,

"id": "tabstextline",

"isVisible": true,

"zIndex": 1

}, {}, {});

Form1.flx.add(tabs);

Thanks

Thx!

@Bevtwiz Cvmpxell Samanthapudi​ Do you also know how to reach a widget that is inside the component after adding it?

I have a component without a contract which has a textbox inside it (mine is called: txtInputText).

I tried:

var numerictext = new inputfields.textnumeric(

{

"clipBounds":true,

"id": "textnumeric",

"isVisible": true,

"zIndex": 1,

"top": "12dp",

"width": "96%",

"centerX": "50%"

}, {}, {});

frmComponent.flcContain.add(numerictext);

and then:

frmComponent.flcContain.textnumeric.txtInputText.text = "12";

but i get an undefined error trying to set the text property.

Hi @Emewson Pvwkew​ ,

Code which you have shared is correct. Please check the id of the textbox is "txtInputText" in the component.

Thank

Hi @Bevtwiz Cvmpxell Samanthapudi​ ,

id seems correct. Check out my screenshot.

Any ideas?**Image removed for security reasons**

Hi @Emewson Pvwkew​ ,

I have tried to replicate the same scenario. It is working fine for me.

If possible can you please share your project.

Thanks

Hi,

Yes I can share my project. Do you have anywhere i can upload it. It is 60mb.

@Bevtwiz Cvmpxell Samanthapudi​ It was smaller then i thought only 32 mb.

Here it is.

Hi @Emewson Pvwkew​ ,

Try providing properties like skin, masterType.

var sample = new com.test.sample({

"clipBounds": true,

"height": "100%",

"id": "sample",

"isVisible": true,

"layoutType": kony.flex.FREE_FORM,

"left": "7dp",

"masterType": constants.MASTER_TYPE_USERWIDGET,

"skin": "slFbox",

"top": "120dp",

"width": "100%",

"zIndex": 1

}, {}, {});

Above is the exact generate code when any component is added to form. You can check the same at <Workspace>\><projectName>\jssrc\<platform>\generated\<form to which component is added.js>

Thank you

@Jovnne Knox​ I tried it, but no luck. Could you please take a look at my project (1 post above yours) and try it out?

@Jovnne Knox​ and @Bevtwiz Cvmpxell Samanthapudi​ any luck trying out my project?

Hi @Emewson Pvwkew​

PFA of formComponent.js . Just replace this file with your.

Thanks

Hi @Bevtwiz Cvmpxell Samanthapudi​ ,

Thanks a lot. It works!