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
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
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.
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.