<layer>
One or more <layer>
elements can be specified within a
<widget class_="text">
. Each <layer>
contains a
1010data query and can be used to provide data to it. (Available as of version
11.09)
Description
One or more <layer>
elements, each containing a 1010data query, may
appear inside the text
widget. Each <layer>
may bear
one or more value*_
(and associated
row*_
/col*_
) attributes) and/or a
tablevalue_
attribute.
Variables set thus by layer queries have scope only in subsequent items (other
<layer>
tags, text, and
<text>
/<html>
/<code>
forms)
within the widget itself; in other words, they do not change the global
<dynamic>
environment and need not be declared in the
<dynamic>
clause.
Syntax
<dynamic> <widget class_="text"> <layer valueN_="[VAR_TO_CHANGE]" rowN_="[ROW_NUMBER]" colN_="[COL_NUMBER]" tablevalue_="@TABLE_VAR"> [1010data_QUERY] </layer> </widget> </dynamic>
Attributes
valueN_
- Accepts an arbitrary variable name. The value corresponding to the
rowN_
and/orcolN_
attributes is stored in the variable associated with thevalueN_
attribute.N
is a string used as an identifier (e.g.,value1_
).More than one value may be stored using multiple
valueN_
attributes, whereN
is a unique identifier for each and must correspond to the naming of the associatedrowN_
and/orcolN_
attributes (e.g.,value1_="[VAR]" row1_="[ROW_NUMBER]" col1_="[COLUMN_NUMBER]" valuefoo_="[VAR]" rowfoo_="[ROW_NUMBER]" colfoo_="[COLUMN_NUMBER]"
, etc.).If a
value_
attribute is specified, but no correspondingrow_
andcol_
attributes, the variable associated with thevalue_
attribute is set to the scalar value in the first row of the first column in the result set of the query (or the empty string if there are no rows in the result set). rowN_
- Specifies a row number within the result set of the query. The value
corresponding to the
rowN_
and/orcolN_
attributes is stored in the variable associated with thevalueN_
attribute.N
is a string used as an identifier (e.g.,row1_
).Together,rowN_
andcolN_
specify the location of a scalar value within the result set of a query.Note: If bothrowN_
andcolN_
are 0, table metadata is saved as a package to the variable associated with thevalueN_
attribute. (Available as of version 11.19)IfrowN_
is provided andcolN_
is omitted, all the values in the row will be stored as a package in the variable associated with thevalueN_
attribute. The keys of the package are the column names in the result set of the query, and the values can be referenced as@[VAR].[COLUMN_NAME]
.Note: If the value ofrowN_
is 0, column metadata is saved as a package to the variable associated with thevalueN_
attribute. (Available as of version 11.19)More than one row value may be specified using multiple
rowN_
attributes, whereN
is a unique identifier for each. Note that the naming of a particularrowN_
attribute must correspond to the naming of the associatedvalueN_
andcolN_
attributes (e.g.,value1_="[VAR]" row1_="[ROW_NUMBER]" col1_="[COLUMN_NUMBER]" valuefoo_="[VAR]" rowfoo_="[ROW_NUMBER]" colfoo_="[COLUMN_NUMBER]"
, etc.).If the value of
rowN_
is a negative number, the row that number of rows back from the last row is used. (Available as of version 11.19) colN_
- Specifies either a column name or column number within the result
set of the query. The value corresponding to the
rowN_
and/orcolN_
attributes is stored in the variable associated with thevalueN_
attribute.N
is a string used as an identifier (e.g.,col1_
).Together,rowN_
andcolN_
specify the location of a scalar value within the result set of a query.Note: If bothrowN_
andcolN_
are 0, table metadata is saved as a package to the variable associated with thevalueN_
attribute. (Available as of version 11.19)IfcolN_
is provided androwN_
is omitted, all the values of the column will be stored as a list-value in the variable associated with thevalueN_
attribute.Note: If the value ofcolN_
is 0, a list of the row numbers is saved as a list-value to the variable associated with thevalueN_
attribute. (Available as of version 11.19)More than one column value may be specified using multiple
colN_
attributes, whereN
is a unique identifier for each. Note that the naming of a particularcolN_
attribute must correspond to the naming of the associatedvalueN_
androwN_
attributes (e.g.,value1_="[VAR]" row1_="[ROW_NUMBER]" col1_="[COLUMN_NUMBER]" valuefoo_="[VAR]" rowfoo_="[ROW_NUMBER]" colfoo_="[COLUMN_NUMBER]"
, etc.).If the value of
colN_
is a negative number, the column that number of columns back from the last column is used. (Available as of version 11.19) tablevalue_
- Accepts the name of a variable to which the
<layer>
can assign the result of the [1010data_QUERY] as a table value.The variable associated with this attribute can be indexed using the following syntax:@foo.bar
provides a list consisting of the values in the columnbar
@foo.17
provides a dictionary consisting of the row 17@foo._cols
provides a list of column names@foo._rows
provides the number of rows
Example: Using <layer>
and <text>
within the
text
widget
<dynamic store="1"> <layout arrange_="v"> <widget class_="dropdown" label_="Select a store" value_="@store"> <table>1;2;3 </table> </widget> <widget class_="text"> <layer value_="@totalsales" row_="1" col_="1"> <base table="pub.demo.retail.item"/> <tabu breaks="store"> <tcol source="sales" name="sumsales" fun="sum" label="Sales"/> </tabu> <sel value="store={@store}"/> <colord cols="sumsales"/> </layer> <text>The total sales for store {@store} is ${@totalsales}. </text> </widget> </layout> </dynamic>
Example: Using <layer>
with tablevalue_
The following example demonstrates how a <layer>
is used to specify a
query that provides data for the text
widget. In this example, the results
of the query is saved in a table-value variable named stores
. That variable
is then accessible to the text specified after the <layer>
tag. The text
references the stores
variable to display the store and city associated
with the selection made in the dropdown
widget.
<dynamic selection="1"> <layout arrange_="v"> <widget class_="dropdown" label_="Select a store" value_="@selection"> <table>1;2;3 </table> </widget> <widget class_="text" visible_="{@selection<>''}"> <layer tablevalue_="@stores"> <base table="pub.demo.retail.store"/> </layer> Store {@stores.store[@selection]} is located in {@stores.city[@selection]}. </widget> </layout> </dynamic>