I. Overview
1.1 Requirement
In designing a dashboard, how to add a Button widget to get the values of other widgets?
1.2 Solution
Get widget names using jQuery:
var a=$('div[widgetname=TEXTEDITOR0]').find('.fr-texteditor').val(); // Get the value of the Text widget textEditor0
var b=$('div[widgetname=COMBOBOX0]').find('.fr-trigger-texteditor').val(); // Get the value of the Drop-down Box widget comboBox0
var c=$('div[widgetname=LABEL0]').find('.fr-label').html(); // Get the value of the Label widget label0
You will learn |
---|
|
II. Sample
2.1 Design of a dashboard
1) Drag a Button widget into a dashboard and name it Get Widget Value, as shown below:
2) Drag a Text widget into a dashboard and assign the value I am a textEditor to it.
3) Drag a Drop-down Box widget into a dashboard and assign the value I am a comboBox to it.
4) Drag a Label widget into a dashboard and assign the value I am a label to it.
2.2 Add a Click event
Click the Button widget and add a Click event, as shown below:
Input the following JavaScript codes:
var a = $('div[widgetname=TEXTEDITOR0]').find('.fr-texteditor').val(); // Get the value of the Text widget textEditor0
var b = $('div[widgetname=COMBOBOX0]').find('.fr-trigger-texteditor').val(); // Get the value of the Drop-down Box widget comboBox0
var c = $('div[widgetname=LABEL0]').find('.fr-label').html(); // Get the value of the Label widget label0
alert(a);
alert(b);
alert(c);
Note: widgetname in JavaScript codes represents the widget name, which should be capitalized.
2.3 Preview