The Repeater Control

The Repeater control can be placed on any form to display a list of records from a dataset. Once placed on a form, the design area of the repeater control is like the Detail design area of a continuous form. After the Data Source property of the Repeater has been set, other controls can be placed within the design area and bound to a Data Field.

Figure 1 displays two Repeater controls: number 1 is a repeater placed on the form while number 2 is placed on a form contained in a subform. When a selection from the first repeater is clicked a filter is applied to the SQL Filter property of the second repeater to limit the records displayed.

Figure 1 : Two Repeater Controls Linked by a Filter

The Repeater control includes a Max Repeats property that can be used to limit the number of rows that are displayed. Setting this number to zero, the default value, means that all rows will be displayed.

The code below shows how the filter example in figure 1 can be implemented. The first section of code is ins the browser code for the main form and the second section contains code for the server side of the subform contained in the promary form.

Browser Code

Procedure Form1.TextLabel2Click(Event: TDOMEvent);
    lblManufacturerId.RepeaterIndex := GetEventRepeaterIndex(Event, RepeaterIndex);
    Subform1.OpenFormExt('formSpecsAndPrice', 0, '"ParamValue=' + lblManufacturerId.Caption + '", "ParamName=ManufacturerId"');

Server Code

Procedure frmSpecsAndPrice.WebFormBeforeExecute(Sender: TWebDocument; Var PContinue: Boolean);
    Repeater1.SQLFilter := '"' + ParamName + '"=''' + ParamValue + '''';

A sample project for the control can be downloaded by clicking here and an online demo can be found here.

Related Topics

Back to top