1. Tracy Lamb
  2. PowerBuilder
  3. Sunday, 26 March 2023 14:57 PM UTC

Hi all,

I'm trying to share data between 2 datawindows.  The Child datawindow that I'm getting is a nested report in a DW that I use to print. They are both the same datawindow, d_print_estimate_detail. GetChild keeps returning -1.  Here's my code for the print button:

DataWindowChild ldwc_PrintEstimate
integer li_rc

li_rc = dw_PrintEstimate.GetChild("d_print_estimate_detail", ldwc_PrintEstimate)
MessageBox("GetChild", li_rc)

ldwc_PrintEstimate.SetTransObject(sqlca)
li_rc = dw_10.ShareData(ldwc_PrintEstimate)
MessageBox("Share Data", li_rc)

TIA,

Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 29 March 2023 21:54 PM UTC
  2. PowerBuilder
  3. # Permalink

This isn't really a solution... I was trying to share data with 2 DWs to avoid having to save the data to the database.  In the end, I decided it's probably a good idea to save the data so I could pull it up again at a later date.

Thanks all for your feedback
~~~Tracy

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 27 March 2023 17:59 PM UTC
  2. PowerBuilder
  3. # 1

Hi Markus;

 Tracy should be able to verify the report name (child DWO) within the parent DWO by expanding the parent DWO in the IDE's "system tree". You would then be able to see all the controls within that object to verify. This is also a handy way to program as any control, column, cc, etc name can then be dragged into the script pane from the system tree. Thus saving keyboard time and/or typing errors.  HTH

Regards ... Chris 

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 28 March 2023 12:07 PM UTC
Hi Markus;

IMHO, always a good day when you learn something new! :-)

Have you hugged a DataWindow today? ;-)

Regards ... Chris
  1. Helpful
  1. Markus Eckert
  2. Tuesday, 28 March 2023 12:34 PM UTC
No, but I would have liked to strangle a particularly stubborn one yesterday.

Does that count as hugging really hard? ;-)
  1. Helpful 3
  1. Miguel Leeuwe
  2. Tuesday, 28 March 2023 12:41 PM UTC
LOL !
  1. Helpful
There are no comments made yet.
Markus Eckert Accepted Answer Pending Moderation
  1. Monday, 27 March 2023 06:56 AM UTC
  2. PowerBuilder
  3. # 2

Hi Tracy

li_rc = dw_PrintEstimate.GetChild("d_print_estimate_detail", ldwc_PrintEstimate)

Just to be sure, are you sure the report control in your datawindow is called "d_print_estimate_detail". (The default name of a report control would be dw_1)

Getchild's first parameter is the name of the control containing the dropdowndatawindow or report, not the name of the dataobject of the child datawindow.

Regards,
Markus

Comment
  1. Miguel Leeuwe
  2. Monday, 27 March 2023 09:35 AM UTC
if the name of the control is not correct, it won't compile and won't let you save any changes.
  1. Helpful
  1. Benjamin Gaesslein
  2. Monday, 27 March 2023 09:53 AM UTC
Miguel, GetChild takes a string as first parameter and this will *not* be checked for validity at compile time. As the help file states:

"Returns 1 if it succeeds and -1 if an error occurs -- for example, if the child object does not exist."



I suspect this might indeed be the reason because Tracy says she has two reports using the same datawindow "d_print_estimate_detail" and calls GetChild using the name of this dw instead of the name of the actual control.
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 27 March 2023 14:11 PM UTC
Ah, yes you are right Benjamin, I thought that Markus was referring to the dw control itself, but he clearly said "report" control. Sorry!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 27 March 2023 02:09 AM UTC
  2. PowerBuilder
  3. # 3

Hi,

If the dot notation doesn't work.

In the past I solved this problem by "temporarily" changing the nested dw's type to be of type "5" ("grid" if I remember well), using Modify().

Modify("Datawindow.Processing=5") then do the GetChild()

After finishing what you're doing change the type back to what it was.

regards.

Comment
  1. Miguel Leeuwe
  2. Monday, 27 March 2023 02:12 AM UTC
BTW: quite some time ago I made a feature request to not have to do this.

https://www.appeon.com/standardsupport/track/view?id=1910

  1. Helpful 1
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Sunday, 26 March 2023 21:08 PM UTC
  2. PowerBuilder
  3. # 4

From the help file, it seems to imply that I can obtain a reference to a nested report...

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:

DataWindowChild dwreport
// Get a reference to the nested report
dw_composite.GetChild("dw_1", dwreport)
dw_tabular.ShareData(dwreport)

 

Comment
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Sunday, 26 March 2023 16:08 PM UTC
  2. PowerBuilder
  3. # 5

I saw that too when researching Chris's feedback.  How can I find out if a DW is a composite or freeform?

 

Comment
  1. John Fauss
  2. Sunday, 26 March 2023 21:11 PM UTC
Check the Processing property of the DataWindow. Refer to PB Help topic "Processing property (DataWindow object) for the syntax. If you only want to check it visually (not programmatically), edit source of a DataWindow Data Object and scan the second line... the one that starts out "datawindow('. Or you can simply perform a Find for "processing=". The numeric value of this property tells you the datawindow style. The values are listed in the PB Help topic.
  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Sunday, 26 March 2023 16:02 PM UTC
  2. PowerBuilder
  3. # 6

Not seeing it Chris.

From the PB help file:
dwcontrol.GetChild(string name, REF DataWindowChild dwchildvariable )

Translated:
parentDW.GetChild("name of nested report", REF to declared DWChild)

In My Case, it should be:
dw_printestimate.GetChild("d_print_estimate_detail", ldwc_PrintEstimate)

That's what I have.

I saw this in the help file:

Nested reports

You cannot use GetChild to get a reference to a report in a composite DataWindow when the report itself is a composite or nested DataWindow.

 

Not sure if this applies or not... the Child I'm getting is a nested report, but the ParentDW is not a composite/nested report.

~~~Tracy

 

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Sunday, 26 March 2023 15:54 PM UTC
  2. PowerBuilder
  3. # 7

Hi, Tracy - 

You stated: "The Child datawindow that I'm getting is a nested report in a DW that I use to print."

Please note this important call-out in the GetChild documentation from PB Help:

Best regards, John

Comment
  1. Chris Pollach @Appeon
  2. Sunday, 26 March 2023 18:41 PM UTC
Hi John;

That is probably the issue John.

Tracy could ...

1) Use DOT notation from the DWO1 to the nested DWO2

2) Use the DW's Modify command to temporarily change the current Nested DWO into a Composite type at runtime so that the GetChild would work.

Food for thought

Regards ... Chris
  1. Helpful
  1. Tracy Lamb
  2. Sunday, 26 March 2023 19:46 PM UTC
Not sure what what you mean here by dot notation?

I'm just trying to get the reference to a nested DW in one DW.

~~~Tracy
  1. Helpful
  1. John Fauss
  2. Sunday, 26 March 2023 22:00 PM UTC
You can "drill down" into nested objects using dot notation. See the following for more information:

https://docs.appeon.com/pb2022/datawindow_reference/XREF_41605_PowerBuilder.html#XREF_96062_Syntax_for_nested
  1. Helpful 1
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.