Dynamic form + dynamic variables

Questions and answers for designing and implementing forms in Servoy

Dynamic form + dynamic variables

Postby DEK4 » Thu Apr 19, 2012 10:24 am

Hello!

I want to edit my form and add new field and variables dynamically, I tried this code:

Code: Select all
function _btnAddElement(event) {
   
   var __sForm = event.getFormName();
   application.output(__sForm);
   var _form = solutionModel.getForm(__sForm);

   var _varTextFiled2 = _form.newFormVariable('variabile',JSVariable.TEXT);
   _varTextFiled2.defaultValue = '"Ciao"';
   _varTextFiled2.variableType = JSVariable.TEXT;

        var field2 = _form.newField(_varTextFiled2,JSField.TEXT_FIELD,2,300,200,25);

   controller.recreateUI();
}


but in this way i create a new field but it isn't associated to the new variable, I think that the problem is the controller.recreateUI() it re-create only the GUI.
User avatar
DEK4
 
Posts: 111
Joined: Wed Oct 12, 2011 9:26 am

Re: Dynamic form + dynamic variables

Postby Andrei Costescu » Thu Apr 19, 2012 2:47 pm

What version of Servoy did you use?
Does if work with a global variable instead of a form variable?

Btw, you are using controller in the last line where I think you would want to use forms[__sForm].controller.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Dynamic form + dynamic variables

Postby DEK4 » Thu Apr 19, 2012 3:14 pm

Servoy version: 6.0.6

i tried with an global variable but nothing, i tried also to put
Code: Select all
forms[__sForm].controller.recreateUI();

but nothing... my textField is empty.

In the debugging i can see my variable but not in the GUI
User avatar
DEK4
 
Posts: 111
Joined: Wed Oct 12, 2011 9:26 am

Re: Dynamic form + dynamic variables

Postby Andrei Costescu » Thu Apr 19, 2012 4:44 pm

Please report this problem.
In my test it does work when I use a global variable:

Code: Select all
solutionModel.newGlobalVariable('variabile',JSVariable.TEXT)
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Dynamic form + dynamic variables

Postby DEK4 » Thu Apr 19, 2012 5:01 pm

With the global variable now works.

I report the problem: https://support.servoy.com/browse/SVY-2047

Thanks for help
User avatar
DEK4
 
Posts: 111
Joined: Wed Oct 12, 2011 9:26 am


Return to Forms

Who is online

Users browsing this forum: No registered users and 8 guests

cron