ShareData – PB Docs 150

ShareData method (DataWindows)

Description

Shares data retrieved by one DataWindow control (or DataStore),
which is referred to as the primary DataWindow, with another DataWindow
control (or DataStore), referred to as the secondary DataWindow.

The controls do not share formatting; only the data is shared,
including data in the primary buffer, the delete buffer, the filter
buffer, and the sort order.

note.png

If you are using ShareData and then use ReselectRow
on the primary DataWindow, the secondary DataWindow resets back
to row 1, column 1.

Controls

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore
object

Web ActiveX

DataWindow control, DataWindowChild object

Syntax

[PowerBuilder]

[Web ActiveX]

Argument

Description

dwprimary

The name of the primary DataWindow. The
primary DataWindow is the owner of the data. When you destroy this DataWindow,
the data disappears. Dwprimary can be a child DataWindow
but it cannot be a report in a composite DataWindow object or a
Crosstab DataWindow object.

dwsecondary

The name of the secondary DataWindow
with which the control dwprimary will share
the data. The secondary DataWindow can be a child DataWindow or
a report in a composite DataWindow object but it cannot be a Crosstab
DataWindow object.

Return Values

Returns 1 if it succeeds and –1 if an error occurs.

Usage

The columns must be the same for the DataWindow objects in
the primary and secondary DataWindow controls, but the SELECT statements
may be different. For example, you could share data between DataWindow
objects with these SELECT statements:

note.png WHERE clause in secondary has no effect

The WHERE clause in the DataWindow object
in the secondary DataWindow control has no effect on the number
of rows returned. The number of rows returned to both DataWindow
controls is determined by the WHERE clause in
the primary DataWindow object.

You could also share data with a DataWindow object that has
an external data source and columns defined to be like the columns
in the primary. To share data between a primary DataWindow and more
than one secondary DataWindow control, call ShareData for
each secondary DataWindow control.

ShareData shares only the primary buffer
of the primary DataWindow with the primary buffer of the secondary
DataWindow. A DropDownDataWindow in the secondary DataWindow will
not display any data unless you explicitly populate it. You can
do this by getting a handle to the DropDownDataWindow (by calling
the GetChild method) and either retrieving the
DropDownDataWindow or using ShareData to share
data from an appropriate data source with the DropDownDataWindow.

To turn off sharing in a primary or secondary DataWindow,
call the ShareDataOff method. When sharing is
turned off for the primary DataWindow, the secondary DataWindows
are disconnected and the data disappears. However, turning off sharing
for a secondary DataWindow does not affect the data in the primary
DataWindow or other secondary DataWindows.

When you call methods in either the primary or secondary DataWindow that
change the data, PowerBuilder applies them to the primary DataWindow
control and all secondary DataWindow controls are affected.

For example, when you call any of the following methods for
a secondary DataWindow control, PowerBuilder applies it to the primary DataWindow.
Therefore, all messages normally associated with the method go to
the primary DataWindow control. Such methods include:

  • DeleteRow

  • Filter

  • GetSQLSelect

  • ImportFile

  • ImportString

  • ImportClipboard

  • InsertRow

  • ReselectRow

  • Reset

  • Retrieve

  • SetFilter

  • SetSort

  • SetSQLSelect

  • Sort

  • Update

There are some restrictions on the use of ShareData:

  • Computed fields in secondary DataWindow controls

    A secondary DataWindow control can have only data that is
    in the primary DataWindow control. If you add a computed field to
    a secondary control, it will not display when you run the application unless
    you also add it to the primary control.

  • Query mode and secondary DataWindows

    When you are sharing data, you cannot turn on query mode for
    a secondary DataWindow. Trying to set the QueryMode or QuerySort DataWindow
    object properties results in an error.

  • Crosstab DataWindows

    You cannot use ShareData with
    a Crosstab DataWindow as the primary or secondary DataWindow.

  • Composite and child DataWindows

    You can use a report in a Composite DataWindow as the secondary DataWindow,
    but not the primary DataWindow. You can use ShareData with
    a child DataWindow as the primary or secondary DataWindow.

  • Distributed applications

    You cannot share data between a DataWindow control in a client application
    and a DataStore in a server application.

note.png Use DataSource with RichTextEdit controls

To share data between a DataStore or DataWindow and a RichTextEdit control,
use the DataSource method.

Examples

In this example, the programmer wants to allow the
user to view two portions of the same data retrieved from the database
and uses the ShareData method to accomplish this
in the script for the Open event for the window.

The SELECT statement for both DataWindow
objects is the same, but the DataWindow object in dw_dept
displays only two of the five columns displayed in dw_employee:

These statements share data between two DataWindow
controls in different sheets within an MDI frame window:

This example shares data in a tabular DataWindow
with a report in a Composite DataWindow. The name of the report
in the Composite DataWindow is dw_1:

See Also


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x