Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

JS Reset the Widget Value

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: Secondary Development
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback