4.1 Walkthrough: Accessing User Selections

Walkthrough

This example uses a RadioButton to give the user a choice of two input options, a Selection List, and a Range Slider. Follow the steps below:

1. Create a new Viewsheet based on the 'ProductSales' Worksheet in the Tutorial folder.

2. Add a table, Selection List, and Range Slider. To do this, follow the steps below:

a. Drag the 'SalesByDate' Data Block into the Viewsheet. This creates a new table called 'SalesByDate'. Resize the table as desired.

b. From the 'SalesByDate' Data Block in the Component tree, drag the 'State' column to an empty region on the Viewsheet. This creates a new Selection List named 'State'.

c. From the Component tree, drag a Range Slider control into the Viewsheet. This creates a new Range Slider.

d. From the 'SalesByDate' Data Block in the Component tree, drag the 'Date' column onto the Range Slider. This binds the Range Slider to the Date field.

3. Create a control to allow the user to select the input method. Follow the steps below:

a. From the Component tree, drag a Radio Button control into the Viewsheet. This creates a new Radio Button.

b. Right-click the RadioButton, and select 'Properties' from the context menu. This opens the 'Properties' dialog box.

c. In the RadioButton 'Properties' dialog box, enter the text “DateOrState” in the 'Name' field. Enter the text 'Selection' in the 'Title' field.

d. In the 'List Values' panel of the 'Properties' dialog box, select 'Embedded' and click the 'Edit' button. This opens the 'Embedded List Values' dialog box.

e. Click 'Add'. For the first 'Label' enter the text “Select Date Range.” For the corresponding 'Value', enter the text “Date”.

f. Click 'Add' again. For the second 'Label' enter the text “Select States.” For the corresponding 'Value', enter the text “State”.

 

g. Click 'OK' in both dialog boxes. This creates a Radio Button with two choices from which the user can select the input method.

 

4. Add expression scripts to the Selection List and the Range Slider so that the appropriate control is enabled for the given user selection. Follow the steps below:

a. Right-click the Selection List, and select 'Properties' from the context menu to open the 'Properties' dialog box.

b. For the 'Enabled' option, click the right-side pop-up menu, and select 'Expression'. Then click the 'Edit' icon to open the Formula Editor.

 

c. In the Formula Editor for the Selection List, enter the following script:

= if (DateOrState.selectedObject=='Date') {

   false

}

else {

   true

}

This indicates that the Selection List control should be disabled whenever 'Date' is selected in the “DateOrState” RadioButton, and enabled otherwise.

d. Click 'OK' twice to exit the Formula Editor and the 'Properties' dialog box.

e. Repeat the above steps for the Range Slider, and set the 'Enabled' script as follows:

= if (DateOrState.selectedObject=='Date') {

   true

}

else {

   false

}

f. Click 'OK' twice to exit the Formula Editor and the 'Properties' dialog box.

5. Preview the Viewsheet, and experiment with the controls.

You can hide the con­trol completely by adding similar scripts (returning values 'Show' and 'Hide') to the 'Visibility' prop­erty.

Note that when you choose 'Select Date Range', only the Range Slider is enabled, and when you choose 'Select States', only the Selection List is enabled.

<< 4 Accessing User Input in Script © 1996-2013 InetSoft Technology Corporation (v11.4) 4.2 Walkthrough: Interactive Chart Drilldown >>