Syntax for nested objects in DataWindow property expressions in PowerBuilder
Description
In PowerBuilder, DataWindow property expressions use additional
Object keywords to refer to nested objects. Nested objects include
composite or related nested reports and child DataWindows associated
with DropDownDataWindow columns. Related nested and composite reports
can include their own nested objects. You can extend the dot notation
to refer to any level of nesting.
Syntax
|
1 |
<span>dwcontrol</span>.Object.<span>nestedcontrolname</span> { [<span>row </span>] } .Object.<span>dwcontrolname</span>. <br> <span>property</span> { .<span>property</span> } { = <span>value</span> } |
|
Argument |
Description |
|---|---|
|
dwcontrol |
The name of the DataWindow control or |
|
Object |
The Object keyword indicates that subsequent |
|
nestedcontrolname |
The name of a DropDownDataWindow column, About nested reports
A nested report can be one of a group of reports in the Composite |
|
row |
When nestedcontrolname is If the report is in a band other than the detail band, it |
|
dwcontrolname |
The name of a control within the nested If dwcontrolname is a column with the DropDownDataWindow |
|
property |
A property that applies to dwcontrolname. For lists of applicable properties, see the |
|
value |
A string whose value is to be assigned For more information, see “Basic syntax for DataWindow |
Datatype
Any. The datatype of the expression is Any, but the actual
data is a string.
For more information about the expression’s
datatype, see “Datatypes of DataWindow
property expressions in PowerBuilder”.
Usage
A nested report within a base report is usually in the detail
band, and each instance of the report is associated with a row.
The property expression must include a row number to identify which
report to access. If the nested report is in a band other than detail,
there may be only one or a few instances of the report, but it is
still associated with a row. The expression must include a row number
that has an instance of the report.
The following table lists the band and the row that is associated
with the report:
|
If the report is in this |
This row is associated |
|---|---|
|
detail |
The specified row. |
|
header |
The first row on the page. On screen, |
|
footer |
The last row on the page. On screen, |
|
header.n (group |
The first row of the group (where n is |
|
trailer.n (group |
The last row of the group (where n is |
|
summary |
The last row in the report. |
Examples
Example 1 Suppose that a DataWindow
has the Composite presentation style and includes a report called
rpt_employee. The report includes a column emp_id.
This expression gets the validation expression for the column:
|
1 |
string ls_valid |
|
1 |
ls_valid = dw_composite.Object.rpt_employee.& |
|
1 |
Object.emp_id.Validation |
Example 2 In a Composite DataWindow,
one of the reports rpt_1 has a graph gr_1. This
example turns on grid lines for the category axis of that graph.
The example sets an instance variable to a default value of “not
found.” If the expression fails and triggers the Error
event, the ExceptionSubstituteReturnValue! action causes the text “not
found” to be returned so that the second assignment succeeds:
|
1 |
is_dwvalue = "not found" |
|
1 |
dw_1.Object.rpt_1.Object.& |
|
1 |
gr_1.Category.MajorGridline = 5 |
|
1 |
st_status.Text = dw_1.Object.rpt_1.Object.& |
|
1 |
gr_1.Category.MajorGridline |
The script for the Error event includes these lines:
|
1 |
action = ExceptionSubstituteReturnValue! |
|
1 |
returnvalue = is_dwvalue |
Example 3 Suppose that a DataWindow
called dw_emp is a base report with employee information.
The detail band includes a nested report of salary history called
rpt_salary. This means there is a separate report with
its own properties in each row.
The script checks whether the employee belongs to management
(the value in the rank column in the base report is M). If so, the
script assigns a DataWindow expression to the Color property of
the salary column in the rpt_salary nested report. The
expression highlights salaries that are over $60,000 in
red.
Another statement sets the salary column’s Mode property
so the color change will be visible:
|
1 |
integer li_row |
|
1 |
|
1 |
FOR li_row = 1 to RowCount( ) |
|
1 |
IF dw_emp.Object.rank.Primary[li_row] = "M" THEN |
|
1 |
|
1 |
dw_emp.Object.rpt_salary[li_row].Object.& |
|
1 |
salary.Background.Color = & |
|
1 |
'255 ~t If(salary > 60000, 255, 0)' |
|
1 |
|
1 |
dw_emp.Object.rpt_salary[li_row].Object.& |
|
1 |
salary.Background.Mode = 0 |
|
1 |
|
1 |
END IF |
|
1 |
NEXT |
Example 4 In this example there
is a graph in the summary band of a base report called dw_emp.
The graph is a nested report called rpt_graph_salaries. Although
the graph is not related to a particular row, you still need to
provide the row number associated with the summary band when you
refer to its properties. This statement turns on autoscaling for
the values axis:
|
1 |
dw_emp.Object.rpt_graph_salaries.Object.& |
|
1 |
gr_1.Values.AutoScale = 1 |
Example 5 If a column has a
DropDownDataWindow edit style, there are properties that affect
the column’s appearance. Using nested object syntax, you can
also change properties of the child DataWindow for the column. In
this example, the DataWindow dw_gift allows a clerk at
a nonprofit organization to record donations. The clerk can pick
a standard donation amount from a drop-down DataWindow.
This example makes the drop-down DataWindow column called
amount a required value and changes the display format for the dollars
column in the child DataWindow:
|
1 |
dw_gift.Object.amount.dddw.Required = "Yes" |
|
1 |
dw_gift.Object.amount.Object.dollars.Format = "$#,##0" |