1. Faisal Hayat
  2. PowerBuilder
  3. Thursday, 14 January 2021 12:52 PM UTC

Hi PB Experts,

Hope Everyone is doing well in this pandemic times. 

I have bumped into an issue and can't find any suitable solution so I decided to ask for your help. Let me explain the situation here.

I have a dw_1, inherited from uo_dw, and it has 30 columns, dw_1 object type is free form and accepts values. on dw_1 there is a column col_1 which has a dddw.

On uo_dw under getfocus event I am changing columns width, dddw no if lines, percent width by using modify. and it helps me to adjust at run time rather changing values in design time for 1000+ objects (DWs).

On w_1 I am using dw_1 and have created an instance type child DW of col_1 of dw_1. This child DW has got some data and need to be used later. BUT when on uo_dw this.modify is applied to col_1 for changing noOfLines for dddw rows in instance Child DW of w_1 gets deleted. This happens only when you are applying modify to col_1 and changing its tooltip properties or no of lines (tested so far) but it does no create any impact when col_1 percentwidth is changed.

As a Workaround or temp solution I can refresh the child DW again or can set its properties so that it passes in getfocus event of uo_dw but it is not a fix for all the objects (DWs which are being inherited from it) and it's a huge application in which I am working. 

I am also reluctant to apply these changes on design time considering the no of objects and time to do it. 

Solution Wanted like 

Should I change the event of uo_dw? If yes which one is suitable for such functionality?

Is there a way to apply modify so that it does impact any child DW created from its column anywhere in the application?

Ken Guo @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 26 January 2021 09:47 AM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Hi All,

As Arnd said, this situation is not supported. You can refer to the link below for details:
https://docs.appeon.com/pb2017r3/datawindow_reference/ch09s48.html
"Changing property values with the Modify method can cause the reference returned by GetChild to become invalid. After setting such a property, call GetChild again. If a property causes this behavior, this is noted in its description in DataWindow Object Properties"

Thus, if you want to alter the DDDW property via Modify, please execute it before GetChild.

Regards,
Ken

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 18 January 2021 16:21 PM UTC
  2. PowerBuilder
  3. # 2
4
Votes
Undo

Faisal - 

I'm able to reproduce the issue using the follow command button Clicked event script in a test application using PB 2019 R2 Build 2353. Although the test app is connected to SQL Server 2017 with the SNC driver, the DataWindow and DataWindowChild  being tested have their data saved internally to the data object and therefore do NOT issue any data retrieve calls.

Integer li_rc
Long    ll_rows
String  ls_desc, ls_modify, ls_result, ls_msg
DataWindowChild ldwc_state

ls_desc = String(dw_1.Describe("state.DDDW.Lines"))
ls_msg  = 'Test 1: The "state" drop-down DataWindow list shows '+ls_desc+' lines.~r~n~r~n'

li_rc = dw_1.GetChild('state',ldwc_state)

If li_rc = 1 Then
   ll_rows = ldwc_state.RowCount()
   ls_msg += 'Test 2: The "state" DataWindowChild contains '+String(ll_rows)+' rows.~r~n~r~n'

   ls_modify = "state.DDDW.Lines=25"
   ls_result = dw_1.Modify(ls_modify)
   ls_msg += 'Test 3: Modify command: "'+ls_modify+'"~r~n~r~nResult: "'+ls_result+'"'

   If Not IsValid(ldwc_state) Then
      ls_msg += 'Test 4: DataWindowChild reference is no longer valid.~r~n~r~n'
      li_rc = dw_1.GetChild('state',ldwc_state)
      If IsValid(ldwc_state) Then
         ls_msg += 'Test 4a: DataWindowChild reference has been refreshed and is now valid.~r~n~r~n'
      Else
         ls_msg += 'Test 4a: DataWindowChild reference could not be refreshed. Exiting now.'
         MessageBox('Child DataWindow Test Results',ls_msg)
         Return 0
      End If
   Else
      ls_msg += 'Test 4: DataWindowChild reference is still valid.~r~n~r~n'
   End If

   ls_desc = String(dw_1.Describe("state.DDDW.Lines"))
   ls_msg += 'Test 5: The "state" drop-down DataWindow list shows '+ls_desc+' lines.~r~n~r~n'

   If IsValid(ldwc_state) Then
      ls_msg += 'Test 6: The DataWindowChild reference is still valid.~r~n~r~n'
   Else
      ls_msg += 'Test 6: The DataWindowChild reference is no longer valid.~r~n~r~n'
      li_rc = dw_1.GetChild('state',ldwc_state)
      If IsValid(ldwc_state) Then
         ls_msg += 'Test 6a: DataWindowChild reference has been refreshed and is now valid.~r~n~r~n'
      Else
         ls_msg += 'Test 6a: DataWindowChild reference could not be refreshed. Exiting now.'
         MessageBox('Child DataWindow Test Result',ls_msg)
         Return 0
      End If
   End If

   ll_rows = ldwc_state.RowCount()
   ls_msg += 'Test 7: The "state" DataWindowChild contains '+String(ll_rows)+' rows.~r~n~r~n'

   li_rc = dw_1.GetChild('state',ldwc_state)
   ls_msg += 'Test 8: GetChild issued RC = '+String(li_rc)+'~r~n~r~n'

   ll_rows = ldwc_state.RowCount()
   ls_msg += 'Test 9: The "state" DataWindowChild contains '+String(ll_rows)+' rows.'
End If

MessageBox('Child DataWindow Test Results',ls_msg)
Return 0

Here are the results when executed from within the PB IDE:

You can see in the line labeled "Test 7" that the RowCount() PowerScript function executed against the valid DataWindowChild reference incorrectly returns a count of zero rows.

By simply refreshing the reference to the DataWindowChild by using the GetChild() function, the abnormality clears up. At no point are the rows in the child DataWindow actually "gone"... if I return from the script immediately after testing the "Test 7" condition, the drop-down opens and displays the information in the child DataWindow with the proper number of rows displayed. The behavior is the same for a variety of DDDW Lines values.

I'm actually surprised the reference to the DataWindowChild remains valid (supposedly) after altering the Lines property, for I expected this action to invalidate the object. As a matter of practice, I always perform another GetChild after altering any DDDW property - and as we see here, this does seem to address the issue.

I suppose you could open a Bug Report on this issue, but with such a simple workaround available, I really don't see the point in doing so.

HTH

Regards, John

 

Comment
Hi John

Thank you very much for your efforts.

Hope you had a good belated Christmas celebrations.



You have come up with a very handy workaround but unfortunately I may not be able to utilize it due to the reason of inheritance. May be you can suggest something here too.



I have a userobject uo_dw which is the parent object for each DW in our application. I am applying modify on parent class, uo_dw, and records are deleted from child DW which is instance variable on a window w_1 whose dw_1 is inherited from the uo_dw.



Surprisingly if I apply modify for percentwidth of dddw then records in child dw are not deleted. :)



Kind Regards

Faisal
  1. Faisal Hayat
  2. Tuesday, 19 January 2021 10:43 AM UTC
This is an old behavior and also documented in the PowerBuilder Help:

https://docs.appeon.com/pb2017r3/datawindow_reference/ch09s48.html

"Changing property values with the Modify method can cause the reference returned by GetChild to become invalid. After setting such a property, call GetChild again. If a property causes this behavior, this is noted in its description in DataWindow Object Properties"



The data is not deleted ... that's what John's Example also shows.

  1. Arnd Schmidt
  2. Tuesday, 19 January 2021 14:23 PM UTC
Arnd is correct. You likely already have the name of the column if you are modifying DDDW properties in code, so all you need to do is refresh the reference to the DataWindowChild object by calling GetChild again after the Modify.

Walk through the code sample I provided line by line and you'll see that is all that I did to resolve the erroneous zero row count.

The data in the child DataWindow (the DDDW) is actually NEVER deleted... but changing the DDDW properties dynamically at execution time (either by using Modify or via dot-notation) causes the DataWindowChild object to become "confused" and make it appear as if it then has zero rows. Performing another GetChild is all you have to do to clear the situation up.
  1. John Fauss
  2. Tuesday, 19 January 2021 14:45 PM UTC
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 14 January 2021 15:13 PM UTC
  2. PowerBuilder
  3. # 3
0
Votes
Undo

Very interesting concept, Faisal!

It sounds like you know your way around working with DataWindowChild objects in PowerScript. Just to be sure, however, I need to ask: Are you performing a GetChild immediately after the Modify to refresh the reference to the child DataWindow? A DataWindowChild reference often becomes invalid when you modify the DDDW-related properties of a column object.

Would you please supply an example of the Modify string (the syntax itself) that is causing rows to be removed from the Child DW so that I can try to reproduce the problem?

John

Comment
Hi John

I have tried couple of things meanwhile but nothing worked. I have tried to modify the DW syntax at run time in constructor, I tried to perform all properties change in constructor with and without post but no luck.



In order to reproduce here are few steps, if it doesn't work let me know and I will try to share a demo code.

Create Userobject uo_dw for DW.

create w_1

create dw_1 on w_1 inherited from uo_dw

dw_1 object should have a column with dddw (col_1) with retrieval arguments

create an instance child DW of col1 on w_1 (icdw_1)

keep instance child dw in watch like (w_1.icdw_1.rowcount())

in getfocus event of uo_dw apply this.modify("col1.dddw.lines=15")

notice that icdw_1 has no rows now.

  1. Faisal Hayat
  2. Friday, 15 January 2021 12:52 PM UTC
To make it more simple

get child DW of dw_1

retrieve the child DW (it should be with argument and return rows)

apply modify to dw_1 like dw_1.modify("col1.dddw.lines=15")

check child DW has lost all rows.



Just to add some spice if you apply modify to the col1.percentwidth child DW will not loose and record. :)
  1. Faisal Hayat
  2. Friday, 15 January 2021 12:55 PM UTC
Thank you for the code snippets and for responding to Chris' questions. I have not yet had a chance to experiment with this information. Yesterday I was able to successfully modify a DDDW from displaying 0 lines (the default, which comes out as 7) to 12 lines using 2019 R2. Have you tried values smaller than 15 lines? I'm curious why you wait to modify the child DW Lines property until the GetFocus event? Have you tried doing this in other place/sequence?

I'm soon to leave town for COVID-postponed Christmas celebration with family, so I will not have a chance to try anything else until Monday.
  1. John Fauss
  2. Friday, 15 January 2021 20:46 PM UTC
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 14 January 2021 13:39 PM UTC
  2. PowerBuilder
  3. # 4
0
Votes
Undo

Hi Fasiel!

   Can you tell us ...

1) PB version & build

2) Does this happen in the IDE, EXE or both

3) Did this issue just start happening?

4) What version of MS-Windows are you using?

5) Do all machines that use the App have the same issue?

Regards ... Chris

 

 

 

Comment
Hi Chris



Here we go



1) PB 2019 R2 Build 2353

2) Both

3) Yes because recently we implemented modify to increase dddw_nooflines at run time for better usability

4) Windows 10 Enterprise Version 1809 Build17763.1637

5) Yes

Kind Regards

Faisal
  1. Faisal Hayat
  2. Friday, 15 January 2021 12:43 PM UTC
Sounds then like the new Modify() command is the source of your issue. In that case, the Debugger could be your friend.
  1. Chris Pollach @Appeon
  2. Friday, 15 January 2021 17:45 PM UTC
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.