JS Assign a Value to a Cell by Clicking a Button

  • Last update:December 15, 2020
  • 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:

     

    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