Create ngclient elements dynamically

Forum to discuss the new web client version of Servoy.

Create ngclient elements dynamically

Postby elias.canales.nieto » Wed Mar 16, 2016 10:59 am

I want to create ngclient elements on the fly, and aggregate it to other elements. Is it that possible?
elias.canales.nieto
 
Posts: 3
Joined: Wed Mar 16, 2016 10:55 am

Re: Create ngclient elements dynamically

Postby Andrei Costescu » Wed Mar 16, 2016 11:34 am

Have a look at 'solutionModel' API. You can create almost anything you want with it (forms/elements included).
Don't know what you mean by aggregating it to other elements.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Create ngclient elements dynamically

Postby elias.canales.nieto » Thu Mar 17, 2016 9:28 am

I know that I can do "var form = solutionModel.newForm('myForm');" and other things like this. But, it is podible to create my own ng-component in a similar way? And how?

Thanks
elias.canales.nieto
 
Posts: 3
Joined: Wed Mar 16, 2016 10:55 am

Re: Create ngclient elements dynamically

Postby Andrei Costescu » Thu Mar 17, 2016 10:29 am

Yes, there is a form method for that. Here is the sample code for it:
Code: Select all
var wc = form.getWebComponent('mycomponent'); // or form.newWebComponent('bean','mypackage-testcomponent',200,200,300,300);
wc.setJSONProperty('mytext', 'Hello World!');
wc.setJSONProperty('mynumber', 1);
wc.setJSONProperty('myborder', 'LineBorder,1,#ccffcc');
wc.setJSONProperty('mydynamicfoundset', { dataproviders: { dp1: "city", dp2: "country" }, foundsetSelector: "" }); // foundset property type using
    // the parent form's foundset and providing two columns of the foundset to client; see foundset property type wiki page for more information


You can see what you should set as a value (in case of more complex properties) by looking at what designer/properties view sets in the .frm file for such properties.
setJSONProperty docs:
Set the design-time value for the given property. For primitive property types you can just set the value.
For more complex property types you can set a JSON value similar to what would be generated in the .frm file if you would design what you need using editor/properties view.
Some property types can be assigned values in the runtime accepted format (for example border, font typed properties have a string representation at runtime and here as well).


Edit: if you are using responsive layout you can also create the needed layout containers using method newLayoutContainer(...).
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Create ngclient elements dynamically

Postby elias.canales.nieto » Fri Mar 18, 2016 9:59 am

Perfect, thank you very much!!
elias.canales.nieto
 
Posts: 3
Joined: Wed Mar 16, 2016 10:55 am

Re: Create ngclient elements dynamically

Postby Andrei Costescu » Fri Mar 18, 2016 2:42 pm

You are welcome! :)
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 10 guests