JS Get or Modify the Value of a Cell which is Bound with a Widge

  • Last update:December 15, 2020
  • I. Overview

    1.1 Requirement

    How to get or modify the value of a cell through JavaScript, as shown below:

    Get the value of a cell:

    Modify the value of a cell:


    1.2 Solution

    Add a button widget and add a JS event to it to get or modify the value of a cell.

    II. Sample

    2.1 Steps

    1) Add two buttons—one is used to get the value and the other is used to assign the value, as shown in the figure below:

     

    2) Add a Click Event to the button used for getting the value:

     

    Input the following JS codes:

    // Get the value of the cell by sheet, column and row numbers
    var v1=contentPane.getCellValue(0,1,3);
    // Get the value of the cell by the column number
    var v2=contentPane.curLGP.getCellValue(3,3);
    //Get the value of the cell by cell name
    var v3=contentPane.curLGP.getCellValue("E4");
    alert("The value of the second column and the fourth row of the first sheet is " +v1+ "\n The value in column 4 and row 4 is " +v2+ "\n The value of cell E4 is " +v3);

    3)Add a JS click event to the Value Assignment button:

     

    Input the following JS codes:

    contentPane.setCellValue(0,1,3,"Male");
    contentPane.curLGP.setCellValue(3,3,"Phone:");
    contentPane.curLGP.setCellValue("E4"null,"19356958746");
    alert("The first row and column 4 of the first sheet were changed to Male \n The third row and column 4 were changed to Phone: \n E4 cell was changed to 19356957746");

    Note

    By inputting the above JS codes, the actual value of a cell will be modified. But if the display value of a cell is modified, it may fail to be submitted for data entry.


    2.2 Preview

    Save the template and click [Data Entry Preview]. The preview effect on a PC is shown as below:

    III. Download the template

    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy