JS Reset the Widget Value

  • Last update:  2020-12-15
  • I. Overview

    How to quickly reset a single widget value or all widget values? Just follow the steps below:

    1.1 Reset a single widget value:


    1.2 Reset all widget values:

     


    1.3 Solution

    • To reset a single widget value, add an event to the widget and assign a null value to it using setValue(""),setText("") and reset(), so that the widget value will be emptied. Reset the widget using reset() on a mobile device.

    • To reset all widget values, fetch all widget values using form.name_widgets, so as to traverse each value for resetting. Input the following JavaScript codes:

    $.each(this.options.form.name_widgets, function(i, item) {
        if(item.options.type !== 'label') {
            item.setValue("");
            item.setText("");
            item.reset();
        }
    });

    II. Sample

    2.1 Reset a single widget value

    2.1.1 Steps

    In the parameter design interface, create a new Button widget and name it Empty Supplier. Add a Click event to enable emptying the values of the supplierID widget. See the demonstration below:

     

    Input the following JavaScript codes:

    //Fetch the supplierID widget
    var supplierID = this.options.form.getWidgetByName("supplierID");
    //Empty the value of the supplierID widget
    supplierID.setValue("");supplierID.setText("");supplierID.reset();

     

    2.1.2 Preview

     

     

    2.2 Reset all widget values

    Take the Empty All button for example to demonstrate how to reset all single widget values.

     

    2.2.1 Steps

    In the parameter interface, create a new Button widget, name it Empty All and add a Click event. See the demonstration below:

     

    Input the following JavaScript codes:

    $.each(this.options.form.name_widgets, function(i, item) {
        if(item.options.type !== 'label') {
            item.setValue("");
            item.setText("");
            item.reset();
        }
    });

     

    2.2.2 Preview

     

    III. Download the template

    Attachment List


    Theme: Parameter
    • 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