Mass set control text

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Mass set control text

#1

Postby Segi » Fri May 09, 2014 8:14 pm

I have many controls that are being displayed in a grid. I named the controls as follows: GRIDCELL_TEXT_1_1_1,GRIDCELL_TEXT_1_1_2, GRIDCELL_TEXT_1_1_3 etc.

In my Javascript Server side script I do a for loop to loop through all the controls mentioned above so I can set all of them with a default text value like this:

Code: Select all

var i,j,k=0;

var currControl;

for &#40; i=1;i<=5;i++&#41; &#123;
     for &#40;j=1;j<=5;j++&#41; &#123;
          for &#40;k=1;k<=10;k++&#41; &#123;
               currControl=controls.getControl&#40;"GRIDCELL_TEXT_" + i + "_" + j + "_" + k&#41;; 
              // does not work
             // currControl.text.setText&#40;"test"&#41;;
          &#125;
     &#125;
&#125;
the problem that I've encountered is that the currControl variable does not have access to the text property (which can be accessed by doing controls.GRIDCELL_TEXT_1_1_1.text.setText())

Is there a way to get a control object via getControl and be able to set its text property ?
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#2

Postby Segi » Fri May 09, 2014 8:33 pm

Found a solution which is not as elegant because you have to loop through all controls on the current page but it works:

Code: Select all

for &#40; var control in Iterator&#40;controls.iterator&#40;&#41;&#41; &#41; &#123;
     if &#40; control.elementType == "Text Control" && control.elementName.substring&#40;0,14&#41; == "GRIDCELL_TEXT_" &#41; &#123;
          control.text.setText&#40;"test"&#41;;
     &#125;
&#125;
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#3

Postby HarryDeBoer » Sun May 11, 2014 12:24 pm

Segi,

you can limit it to the grid by looping through it's childcontrols:

for each (var control in controls.GRIDCONTROL1.childControls) //returns GRIDCELLx
{
for each (var ch_control in control.childControls) //returns controls in the cell
{
if ( ch_control.elementType == "Text Control" && ch_control.elementName.substring(0,4) == "TEXT" )
{
ch_control.text.setText("test");
}
}
}
0 x
Kind regards,

Harry

Dave
Ebase Staff
Posts: 89
Joined: Mon Sep 10, 2007 11:48 am

#4

Postby Dave » Wed May 14, 2014 8:13 am

Modifiers are quite handy for this sort of thing. For example, assign a Modifier of value A to each control in your grid, and then

Code: Select all

var page = pages.PAGE_1;
for each &#40;var ctrl in page.getControlsByModifier&#40;"A"&#41;&#41;&#123;ctrl.text.setText&#40;"test"&#41;;&#125;
Dave
0 x


Who is online

Users browsing this forum: No registered users and 4 guests