280 likes | 529 Views
IA 345 What Every PowerBuilder Developer Needs to Know about DropDown DataWindows. Tom Bartha Principal Consultant PricewaterhouseCoopers tom.bartha@us.pwcglobal.com. To explore what is inherent in a DDDW versus what a PowerBuilder developer has to provide.
E N D
IA 345What Every PowerBuilder DeveloperNeeds to Know aboutDropDown DataWindows • Tom Bartha • Principal Consultant • PricewaterhouseCoopers • tom.bartha@us.pwcglobal.com
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/presenters Objectives of this Session
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. Before DropDown DataWindows
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: Before PowerBuilder 3.0
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) Code Example for Cursor
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 Code Example for Cursor (continued)
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.” DropDown DataWindow Definitions
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.” DropDown DataWindow Definitions (continued)
Use of DropDown DataWindows • 1. Data Entry
Use of DropDown DataWindows • 2. Data Display and Reports
Use of DropDown DataWindows • 3. Search DataWindows
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 Creating a DropDown DataWindow
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. Exclusive DropDown DataWindows
Exclusive DropDown DataWindows (continued) Demonstration
Default Process Parent Managing the Child Multiple dddw’s in Parent Frequently Used dddw Result Sets Infrequently Used dddw Result Sets Populating DropDown DataWindows
DDDW Retrieval Arguments • DDDW may or may not have retrieval arguments • If not programmed you get the retrieval argument dialog window
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 DDDW’s with Retrieval Arguments
Storing 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
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 child’s handle. Use GetChild function: dw_control.GetChild(col_name, child_handle) Child DataWindows
A child datawindow works in very close conjunction with its parent: The child picks up the parent’s 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. Overriding the Default Process
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( ) Overriding the Default Process (continued)
ELSE MessageBox(“DataWindow Error”, “Unable to obtain dddw handle.”) END IF Overriding the Default Process (continued)
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 dddw’s retrieve your DataWindows in a normal way. Sharing Hidden DDDW’s
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 dddw’s only if the user clicks on the corresponding columns. (see demonstration) Infrequently Used DDDW Result Sets
Synchronized DDDW’s Retrieve Arguments vs Filtering Adding data elements to a dddw on the fly Cascading dddw’s Code Examples
Slide title, may be two lines, Arial Black, 32 pt. Color Palette Arrow Style
100 90 80 70 60 50 40 30 20 10 0 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr Slide title, may be two lines, Arial Black, 32 pt.