Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

JS Get all values of extended widget

I. Overview

1.1 Problem

When a data entry report is displayed, the reporting widget is extended. As shown in the figure below, we can get all the extended values of the radio button group widget:

1.gif


1.2 Solution

Add a click event to the button to traverse the widget, if there is only one, get its value; if there are multiple, traverse to get all the values.

II. Example

2.1 Add a extended widget

Create a new template, right-click cell C7 to add a radio button group widget, and set the widget name to p1:

2.png

Set the C7 cell to expand vertically:

3.png

Add a data dictionary to the radio button group: 

4.png

Right-click the cell D7, add a button widget, set the button type to be insert row, and specify the cell as C7:

5.png


2.2 Get extended widget value

Add a button widget in cell C9, and add a click event:

6.png

JavaScript:

var temp="";
var arr=contentPane.getWidgetsByName("p1"); 
if(arr[0]!=undefined)
{
   for(var i=0;i<arr.length;i++)
   {temp = temp + arr[i].getValue() + ' ';}
}
else 
   {temp=arr.getValue()
}
alert(temp);


2.3 Preview effect

Save the template, click data entry preview , the effect is shown in the figure below:

7.gif


III. Download template

Attachment List


Theme: Secondary Development
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback