Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Advanced PowerBuilder

HomePrevious Lesson: The DW Syntax Tool
Next Lesson: Summary

Creating DataWindows Dynamically

PowerBuilder allows you to create a DataWindow dynamically at execution time by using Create() function. For example, say, you display a list of columns to the user and let him pick the ones he want to see in the report. In such a case, at painting time, you will not know anything about the appearance of the finished DataWindow.

When having a DataWindow or the custom user object control on your window, you need to complete the three steps involved in the dynamic creation of a DataWindow, in your script:
Dynamically build a SELECT statement and place it in a string variable.
Create the DataWindow syntax by calling SyntaxFromSQL().
Create the DataWindow from the syntax by calling Create().

You can then set the transaction Object and retrieve the data as normal. The reason we call SyntaxFromSQL()is, that the syntax for a DataWindow is different from the SELECT statement;  it also contains the column attributes such as font details, colors and so on, as well as other attributes such as band details. A sample of a DataWindow's syntax is shown below:

release 4;

DataWindow(units=0 timer_interval=0 color=1073741824 processing=1 print.margin.bottom=97 print.margin.left=110 print.margin.right=110 print.margin.top=97)

table(column=(type=decimal(0) update=yes key=yes initial="0" name=product_no dbname="product_master.product_no")

As an example, the following script creates a grid style DataWindow and retrieves data from product_master:

String lSQLStr, lErrorStr, ldwSyntax
Integer lResult

lSQLStr = "select product_no,product_description,product_balance"+ &
          " from product_master"

ldwSyntax = SQLCA.SyntaxFromSQL( lSQLStr, "style &
                  (type=grid)",lErrorStr )
lResult = dwc_1.Create( ldwSyntax, lErrorStr )

dwc_1.SetTransObject( SQLCA )
dwc_1.Retrieve()

SyntaxFromSQL() takes three parameters: a SELECT statement, a style and a string variable to populate any error information. The style attribute is the most complex parameter. The syntax is as follows:

"Style(Type=value attribute=value ...) &
DataWindow(attribute=value ...) &
Column(attribute=value ...) &
Group(groupby_col1 groupby_col2 ... attribute ...) &
Text(attribute=value ...) &
Title('titlestring') "

Tabular DataWindow style is the default, and to assume the default values, simply specify an empty string as the parameter.
Note that the Composite presentation style is not supported in this method.

Again, the simplest way to create this syntax is to use DW Syntax with the Create option.

This results in the CREATE statement being pasted directly into the code.
HomePrevious Lesson: The DW Syntax Tool
Next Lesson: Summary

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com