Nested Tables
Changing child controls dynamically
See also: Table Basics, Table Control, Repeater Control, Table Display Features, FPL Command Syntax
It is possible to include either a Table Control or a Repeater Control as a child of another Repeater Control; it is not possible to include a Table Control as a child of another Table Control.
Nested child tables are implemented using the filter expression property of either a Table Control or a Repeater Control. Each child control will be displayed multiple times (once for each instance of its parent) but all child instances are backed by a single copy of the table linked to the child control. As each instance of the child control is prepared for output, the filter expression is applied to each row of the associated table to limit the rows displayed. Nested tables are achieved by using a filter expression equivalent to:
child_table_parent = parent_table_key
It is important to realise that the filter is applied when an output page is displayed, and that the filter is applied to the control and not the associated table. Any scripts that loop through the rows of a child table will process all rows.
Please note that the underlying table linked to a nested Table Control or Repeater Control should not be the same table as linked to the parent Repeater Control i.e. when nesting tables/repeaters, different tables should be specified.
The filter expression is an FPL boolean expression that must result in either true or false.
The example below shows a child Table Control (orders) nested within a parent Repeater Control (customers):
The parent table (CUSTOMERS) is backed by a database resource with SQL of: select * from customers. The customers database table has a key of customer_id. This table is displayed by Repeater Control CUSTOMERS_CONTROL.
The child table (ORDERS) is backed by a database resource with SQL of: select * from orders. The orders database table has a key of customer_id + order_id. This is displayed by Table Control ORDERS_CONTROL. Note that there is only one table which is providing the data for all instances of the repeating ORDERS_CONTROL Table Control. The ORDERS_CONTROL Table Control has a filter expression of:
customers-customer_id=orders-customer_id
This is applied to each instance of ORDERS_CONTROL as it is displayed and has the effect of only displaying those orders applicable for each customer.
Both tables are loaded with a script containing:
fetchtable CUSTOMERS;
fetchtable ORDERS;
The controls are arranged on the page as shown below:
ORDERS_CONTROL properties showing the filter expression:
Dynamic changes can be made to any child control of a nester Repeater Control e.g. hide/show a control or change color etc, by setting the current row of all parent tables. Click here for an example.