Title: IA 345 What Every PowerBuilder Developer Needs to Know about DropDown DataWindows
1IA 345What Every PowerBuilder DeveloperNeeds to
Know aboutDropDown DataWindows
Tom Bartha Principal Consultant PricewaterhouseCoo
pers tom.bartha_at_us.pwcglobal.com
2Objectives of this Session
- To explore what is inherent in a DDDW versus what
a PowerBuilder developer has to provide. - To demonstrate basic and developer provided
functionality. - To provide a full text version of this
presentation. - All code examples will be available on the
Presenters Web Page www.sybase.com/techwave2000/p
resenters
3Before DropDown DataWindows
- Regardless of ever increasing computing resources
at an ever decreasing cost, we need to store some
data in codified manner. - To display full data value corresponding to coded
information we often resort to drop-down lists. - Drop-down lists representing constantly changing
data needs to be dynamically populated. - Prior to PowerBuilder 3.0 this required work.
4Before PowerBuilder 3.0
- In order to populate a ddlb with data from a
table, we had to - Declare a cursor
- Open the cursor
- Fetch the data into the code table of the ddlb
one at a time - In the open event of the window (parent of ddlb)
you would have the following script
5Code Example for Cursor
- integer li_counter
- string Is_state_id, Is_state_name
- DECLARE state_cursor CURSOR FOR
- Select state_id, state_name
- From states_table
- Using SQLCA
- OPEN state_cursor
- (continued)
6Code Example for Cursor (continued)
- Do WHILE sqlca.sqlcode 0
- Fetch state_cursor INTO Is_state_id,
- Is_state_name
- IF sqlca.sqlcode 0 THEN
- ddlb_data.SetValue("state", li_counter,
- Is_state_name "-t"
- string(Is_state_id))
- END IF
- li_counter
- LOOP
- Close state_cursor
7DropDown DataWindow Definitions
- Definitions in Help and the On-line Books
- A DataWindowChild object is a nested report or a
DropDown DataWindow within a DataWindow object.
For example, a DataWindow object that populates a
column having the DropDownDataWindow edit style
is a DataWindowChild object.
8DropDown DataWindow Definitions (continued)
- Definitions in Help and the On-line Books
- A DataWindowChild object is used for accessing
DataWindow objects independently from DataWindow
functionality, and it inherits from the system
Structure object because it needs storage and
autoinstantiation. - A DataWindowChild object has no properties and
no events, but it does have functions.
9Use of DropDown DataWindows
10Use of DropDown DataWindows
- 2. Data Display and Reports
11Use of DropDown DataWindows
12Creating a DropDown DataWindow
- Define a datawindow object
- Nest this datawindow object inside a parent
datawindow - Build another datawindow as parent
- OR
- Use an exisiting multi-column datawindow as parent
13Exclusive DropDown DataWindows
- Option A
- Create a new datawindow object using the same
table as the one the dddw is defined on. - Option B
- Create a new free-form external datawindow
object. - Option C
- Use recursion, namely, place the dddw inside
itself.
14Exclusive DropDown DataWindows (continued)
15Populating DropDown DataWindows
- Default Process
- Parent Managing the Child
- Multiple dddws in Parent
- Frequently Used dddw Result Sets
- Infrequently Used dddw Result Sets
16DDDW Retrieval Arguments
- DDDW may or may not have retrieval arguments
- If not programmed you get the retrieval argument
dialog window
17DDDWs with Retrieval Arguments
- PowerBuilder will attempt to Retrieve a DDDW if
the DDDW has no rows in the Primary Buffer - Overriding the Default Process
- Preload a blank row
- Retrieve the DDDW before the main DW
- Using Retrieval Arguments
- Retrieve dddw when window opens
- Retrieve dddw when something changes
18Storing Data in a DataWindow Object
- Rows Data in DW Painter
- Data are stored with the DW
- Data are automatically displayed in the
DataWindow when it is instantiated
19Child DataWindows
- A child datawindow is any datawindow which is
nested inside another datawindow and, therefore,
dependent on its parent. - The child does not have a name accessible at the
window level. - We must define a variable of type datawindowchild
and trap the childs handle. - Use GetChild function
- dw_control.GetChild(col_name, child_handle)
20Overriding the Default Process
- A child datawindow works in very close
conjunction with its parent - The child picks up the parents transaction
object. - The child will retrieve its result set from the
database when the parent is retrieved. - To override these defaults we must remember that
as long as the child datawindow has a valid
result set, no new result set will be retrieved
by default.
21Overriding the Default Process (continued)
- Script in the open event of the window
- integer li_return
- datawindowchild ldwx_dept
- dw_parent.SetTransObject(sqlca)
- // Obtain the handle of the dddw in the
department column - li_return dw_parent.GetChild(dept_id,
ldwc_dept) - IF li_return 1 THEN
- ldwc_dept.SetTransObject(sqlca)
- ldwc_dept.InsertRow(0)
- dw_parent.Retrieve( )
22Overriding the Default Process (continued)
- ELSE
- MessageBox(DataWindow Error, Unable to obtain
dddw handle.) - END IF
23Sharing Hidden DDDWs
- Create a non-visual object.
- Define an instance array of DataStores.
- Add a method to share data.
- Call the method to share from the DataWindows
that need caching. - After sharing dddws retrieve your DataWindows in
a normal way.
24Infrequently Used DDDW Result Sets
- Problem On the parent datawindow there are a
number of dddw columns, each of which contains a
large number of rows. Not all the result sets
are needed at the same time or even in one user
session. - Want to avoid the retrieval time, unless result
set is needed. - Solution Populate the dddws only if the user
clicks on the corresponding columns. - (see demonstration)
25Code Examples
- Synchronized DDDWs
- Retrieve Arguments vs Filtering
- Adding data elements to a dddw on the fly
- Cascading dddws
26Slide title, may be two lines, Arial Black, 32
pt.
Color Palette
Arrow Style
27Slide title, may be two lines, Arial Black, 32
pt.