How to use JavaScript to solve the untimely refresh of control values in FineReport

We often use buttons to process some page values, but the default logic results in that each time a new value is filled in, it needs to click on the blank area or perform some other operation to be correctly read, so how do we deal with it?

Example: When we use the conventional value, although the value is entered in the B3 cell, but on the premise that the cursor does not leave the B3, the JS only gets the control instead of the actual value "2".

To get the value of B3, you need to click the mouse in the blank space to make the red triangle appear in the upper left corner of the text box.

After optimization, you can force the cursor to jump to the A2 cell, so that it can get the cursor, and then force the B3 cell to refresh the value.


 

Since you can click on the blank space arbitrarily, then we use JS to force the jump cursor to achieve the same function.

Template making

The template style is designed as follows, adding text controls to cells A3 and B3, adding values ​​to cells A3 and B3 in cell C3, and adding button controls to cells D3 and E3:


 

JS for "Add Directly" button

D3 control name is direct addition, add a click event

 

var B3 = contentPane.curLGP.getCellValue("B3");
var A3 = contentPane.curLGP.getCellValue("A3");
alert("value of a3:"+A3);
alert("value of b3: "+B3);

 

JS for "After optimization" button

After the E3 control name is optimized, add a click event

 

contentPane.curLGP.selectTDCell("A2");
 
var B3 = contentPane.curLGP.getCellValue("B3");
var A3 = contentPane.curLGP.getCellValue("A3");
alert("value of a3:"+A3);
alert("value of b3: "+B3);

  

contentPane.curLGP.selectTDCell("A2"): Indicates that the cursor is forced to jump to the A2 cell, which is equivalent to clicking the A2 cell with the mouse to make it get the cursor, and then force the B3 cell to refresh the value .

Common scenarios

用户通过文本框填报了值,而需要对这个值进行取出判断的时候,经常会取空值,只有用户点击了空白区域,才可以正常取值。

比如:用户填写了手机号码,就可以跳转到领取奖品的页面,若手机号码是最后一个填报栏,填写后,用户直接提交,系统则会认为,手机号码一栏为空。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326879502&siteId=291194637