Referencing a Query Column

You can reference all cells of a field (column) in the result set by using the field name:

q['state'];

The following example illustrates this approach.

Walkthrough

Consider the sample 'customers' query. In this example, you will extract all the values under the 'state' column and use them to populate a formula table. Follow the steps below.

1. Click the 'New' button in the Style Studio toolbar. This opens the 'New Asset' dialog box.

2. In the left panel, select 'Report'. In the right 'Types' panel, select 'Blank Tabular Report' and click 'OK'.

3. Expand the Style Studio Toolbox panel, and drag a Table element into the report. This creates a new blank Table.

4. Right-click the table, and select 'Table' > 'Convert to Formula Table' from the context menu.

5. Right-click the table, and select 'Table' > 'Insert Rows/Columns' from the context menu.

6. Insert two additional columns so that the table has two rows and four columns.

7. Click away from the Table to deselect it.

8. Expand the Style Studio Properties panel. (Select 'Properties Pane' from the Style Studio Window menu.) Click the Script tab in the Properties panel.

9. Select the 'onLoad' button in the Script tab, and enter the following script:

var q = runQuery('customers')

This executes the 'customers' query in the onLoad script. (See Extracting Data from a Query for more details.)

10. Click cell[1,0] in the Table (second row, first column) to select it.

11. Click the Data tab in the Properties panel. Select the 'Formula' button in the 'Binding' section, and enter the following formula for cell[1,0]:

q['state']

This extracts the entire 'state' column from the 'customers' query to populate the table.

12. In the 'Expansion' region of the Data tab, select 'Expand Cell' and choose 'Vertical'. (This causes the extracted data to fill down vertically.)

13. Preview the report and see how the table is populated with all of the records from the 'state' column.

 

<< 3.7.3 Referencing Query Data © 1996-2013 InetSoft Technology Corporation (v11.4) Deriving a Result Set from Query Columns >>