I. Overview
1.1 Requirement
How to assign a value to a cell by clicking a button?
1.2 Solution
Add a click event to the button widget to modify the value of a cell.
II. Sample
2.1 Steps
1) Create a new template and enter “Relieving abnormal” in A1 and “abnormal” in B1.
2) Add a button widget in A1 and set the [Widget Name] as [anniu].
3) Add a click event to the button widget.
Input the following JS codes:
var Widget=contentPane.getWidgetByName("anniu");
if(contentPane.curLGP.getCellValue("B1")=="abnormal"){
Widget.setText("Abnormal setting");
contentPane.setCellValue("B1",null,"normal");
} else{
Widget.setText("Relieving abnormal");
contentPane.setCellValue("B1",null,"abnormal");
}
$('.dirty').removeClass('dirty');
2.2 Preview
Save the template and click [Data Entry Preview]. The preview effect is shown as below: