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.
integer dwprimary.ShareData ( datawindow dwsecondary )
integer dwprimary.ShareData ( datastore dwsecondary )
integer dwprimary.ShareData ( datawindowchild dwsecondary )
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. |
dwsecondary |
The name of the secondary DataWindow with which the control dwprimary will share the data. The secondary DataWindow cannot be a Crosstab DataWindow. It can be a child DataWindow. |
Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, ShareData returns NULL.
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:
SELECT dept_id from dept
SELECT dept_id from dept where dept_id = 200
SELECT dept_id from employee
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, PocketBuilder 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, PocketBuilder 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
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.
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:
CONNECT USING SQLCA;
dw_employee.SetTransObject(SQLCA)
dw_employee.Retrieve()
dw_employee.ShareData(dw_dept)
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |