I. Overview
When in data entry, it is often necessary to use JavaScript for secondary development of some functions, such as setting whether the widget can be edited, assigning values to cell, and so on.
Like JS instances of parameter pane, first of all we need to get the data entry widget or a cell in order to operate.
Different from the parameter pane JS: in the case of the data entry preview, the cell and the report widget are in the same position. After the widget is edited, the value will be automatically passed to the cell where the widget is located. Therefore, both the cell and the widget object can be obtained. But only when obtaining the cell, can you assigning values.
II. Example
2.1 Get the value of a cell
There are several ways to get the value of the cell on the data entry report:
contentPane.getCellValue(sheet number, column number, row number); //sheet number, row number, column number start from 0
contentPane.curLGP.getCellValue(column number, row number);
contentPane.curLGP.getCellValue(cell);
contentPane.curLGP._get$TDCell(col,row).text();//Get the cell display value
contentPane.curLGP._get$TDCell(cell).text();
Since the cells may change the displayed value, JavaScript can get the cell actual value and the displayed value.
Note: contentPane.curLGP.getCellValue (column number, "A1") cannot be used when using contentPane.curLGP.getCellValue (column number, row number) to get the value. Assign the value of cell A1 to a variable first, and then replace it with the variable.
2.2 Assign the value to a cell
The method of value assignment is also divided into the case of assigning to the displayed value and assigning to the actual value:
contentPane.setCellValue(sheet number, column number, row number, value); //sheet number, row number, column number start from 0
contentPane.curLGP.setCellValue(column number, row number, value);//Assign display value to the cell. Not the actual value, and cannot be submitted
contentPane.curLGP.setCellValue(cell, null, value);//Assign display value to the cell. Not the actual value, and cannot be submitted
contentPane.setCellValue(column number, row number, value);//Assign the actual value to the cell, you can submit it
contentPane.setCellValue(cell,null,value);//Assign the actual value to the cell, you can submit it
2.3 Get the row and column number of current cell
The above acquisition and assignment of cell values are performed when the row and column number of the cell is determined. If the cell row and column number is dynamic, for example, to modify the value of the cell currently being edited, refer to the JavaScript as follows:
contentPane.curLGP.getTDRow(contentPane.curLGP.currentTDCell)//Get current row number
contentPane.curLGP.getTDCol(contentPane.curLGP.currentTDCell)//Get current column number
2.4 Conversion between col/row number and cell number
1) Convert row and column number to cell
FR.columnRow2CellStr({col:1, row:0});//It will return B1
2) Convert cell to rol and column number
FR.cellStr2ColumnRow('B1');
2.5 Get report widget
The data entry report object can be obtained directly by using the contentPane, and then the widget object can be obtained by different methods:
1) Get a single widget object
contentPane.getWidgetByName("widgetname");//Get the widget object according to the name
contentPane.getWidgetByCell("Cell");//Get the widget object according to the cell position
2) Get the extended widget object
The report widget is bound to the cell. If the cell is expandable, so are the widget and widget name. The JavaScript method to get multiple widgets with the same name is:
contentPane.getWidgetsByName("widgetname")//This will return an array
2.6 Report widget methods
After obtaining the widget, you need to operate the widget. For example, you can get its value, set whether the widget is visible, and so on. Methods as below:
Method name | Method | Description |
---|---|---|
Take actual value | Widget.getValue() | Get the actual value of the widget |
Take displayed value | Widget.getText() | Get the display value of the widget |
Assign actual value | Widget.setValue() | Assign the actual value to the parameter widget; it is not recommended to apply to the report widget |
Assign displayed value | Widget.setText() | Assign the display value to the parameter widget; it is not recommended to apply to the report widget |
Reset | Widget.reset() | Clear data |
Set visible | Widget.visible() | Set the widget to be visible |
Set invisible | Widget.invisible() | Set the widget to be not visible |
Is it visible | Widget.isVisible(boolean) | Returns whether the widget is visible, return true for visible, false for invisible |
Set visibility | Widget.setVisible(boolean) | Set whether the widget is visible, the parameter is true to be visible, false to be invisible |
Set availability | Widget.setEnable(boolean) | Set whether the widget is enabled, the parameter is true to be enabled, false is off |
Is it enabled | Widget.isEnabled() | Return whether the widget is enabled, return true for enabled, false for off |
Call widget event | Widget.fireEvent("Event Name") | Call the event with the specified name of the widget |
Can it be empty | Widget.options.allowBlank=false | Set whether the widget can be empty, true can be empty, false can not be empty |
Where Widget is the obtained widget object.
Note:
If you use setValue() to assign a value to the drop-down tree you need to add a false parameter, namely setValue(value,false), and value is the value that needs to be assigned to the drop-down tree
The last value displayed on the data entry report is the value of the cell. Edit data by filling in the widget. When the editing is over, the widget will automatically transfer the value to the current cell. Therefore, if you assign a value to a widget, it can only be displayed in the cell when the assigned widget is in the editing state; if the widget is out of editing state, widget assignment method will not work.