1. James Medick
  2. PowerBuilder
  3. Monday, 13 September 2021 16:56 PM UTC

I'm missing something very simple.  I do a GetChild on a dddw to filter the column.  The filter works fine except that for the first time, when I click on the column, the display changes to the code value of the current item, it does not retain the display value.  Then if any time is selected, the display always shows and everything is fine.  

I've seen lots of comments on filtering dddws but can't seem to find something that works.  I must be overlooking something?

James

Accepted Answer
James Medick Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 15:58 PM UTC
  2. PowerBuilder
  3. # Permalink

It appears that this code is the culprit:

For ll_col = 1 to Long( Tab_1.TabPage_1.dw_1.Object.DataWindow.Column.Count )
  Tab_1.TabPage_1.dw_1.Modify( "#" + String( ll_col ) + ".Protect = 1" )
Next

Executing this code prior to the GetChild (using filter or not), causes the first access of the DDDW to lose its display.  This may be a small bug, not sure,  the combination of protecting and then unprotecting a column in conjunction with a GetChild.

Thanks to all for the help.

James

 

 

Comment
  1. John Fauss
  2. Tuesday, 14 September 2021 16:30 PM UTC
Glad to hear you found the cause of the problem, James!
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Tuesday, 14 September 2021 20:12 PM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 16:15 PM UTC
  2. PowerBuilder
  3. # 1

Slight clarification.

Using Modify to protect the column immediately prior to the dddw causes the dddw to lose the display when first accessed.

Comment
  1. Miguel Leeuwe
  2. Tuesday, 14 September 2021 16:25 PM UTC
That might be very true. I pretty much find the protect attribute useless because of code failing to do anything on a protected column. When setting a column as protected you also always have to make sure that the cursor is not in that column. I'ts much better to set the tabsequence of a column to 0 if you want to protect it.

What we do in the constructor of a dw is get all the initial tabsequences into an array. That way we can restore the initial tabsequence after having set it to 0 to protect a column.

Just an idea.

regards.
  1. Helpful 1
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Monday, 13 September 2021 22:51 PM UTC
  2. PowerBuilder
  3. # 2

Just to be clear, there is only one row in the data window.  All values in the dddw are present for the filter, "S", "R", "A" and more.  I guess that's why it works the second and subsequent times.

I've tried placing the retrieve and filter statements in all different orders.  Nothing makes any difference.  Its like the first time the column gets focus it loses the display.

Comment
  1. John Fauss
  2. Tuesday, 14 September 2021 15:12 PM UTC
If the steps work fine after the initial time the column gets focus, then it's likely the order in which the commands are being done OR because the column has focus before you are making the child DW changes. maybe dynamically change the Protect setting is a factor? As an experiment, try setting the tab order to the second column so that it gets focus first, just to see what happens. I'd also try commenting out the Protect modify command temporarily to see what that does. I also note you are not assigning the return code value from any of the child DW manipulation functions to a variable and wonder if that would lend any insights with use of the debugger the first time thru the code.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Tuesday, 14 September 2021 16:27 PM UTC
I rarely protect columns, prefer to set the tabsequence to 0.

regards
  1. Helpful
There are no comments made yet.
Shekar Reddy Accepted Answer Pending Moderation
  1. Monday, 13 September 2021 22:29 PM UTC
  2. PowerBuilder
  3. # 3

If you filtered out the corresponding row from the DDDW matching the value of the column, DDDW will display data value because it doesn't have the row. If you select an item from the filtered DDDW, it will display the display value because the row exists in the DDDW.

As a workaround, duplicate the DDDW column inside the DW, overlay them one over the other, set their visible property based on the current row and - apply filter on one DDDW column and no filter on the other DDDW. Filtered DDDW will be visible for the current row only to validate input and unfiltered DDDW will be visible for all other rows to show display values (regardless of if the DDDW is filtered or not).

When you duplicate the column, do not change the column name given by the DW.

HTH

PowerObject!

Comment
There are no comments made yet.
James Medick Accepted Answer Pending Moderation
  1. Monday, 13 September 2021 20:15 PM UTC
  2. PowerBuilder
  3. # 4

Hi John,

I'm using Windows 10, PB 2019 R3 Build 2703.

1.  Data type of the column (index) is String (char 1)

2.  Properties:

  a.  Required

  b.  Always Show Arrow

  c.  AutoRetrieve (off)

  d.  DataWindow dddw_approval_status

  e.  Display Column  Approval_status

  f.  Data Column  idapproval_status

3.  Code:

datastore lds_staging
lds_staging = CREATE datastore
lds_staging.DataObject = "d_expense_staging_load"
lds_staging.SetTransObject (SQLCA)
lds_staging.Retrieve(il_master)
ii_approver = lds_staging.GetItemNumber(1, "stager")


For li_col = 1 to Long( Tab_1.TabPage_1.dw_1.Object.DataWindow.Column.Count )
Tab_1.TabPage_1.dw_1.Modify( "#" + String( li_col ) + ".Protect = 1" )
Next

ls_status = Tab_1.TabPage_1.dw_1.GetItemString(1, "status")

Choose Case ls_status
Case "S"
If ii_approver = g_loggedon_emp_no Then
Tab_1.TabPage_1.dw_1.Modify("status.Protect = 0")
Tab_1.TabPage_1.dw_1.Modify("return_reason.Protect = 0")
Else
Tab_1.TabPage_1.dw_1.Modify("status.Protect = 1")
Tab_1.TabPage_1.dw_1.Modify("return_reason.Protect = 1")
End IF
ls_filter = "idapproval_status= 'S' Or idapproval_status= 'A' Or idapproval_status= 'R'"
Case Else
Tab_1.TabPage_1.dw_1.Object.DataWindow.Readonly = True
End Choose

DataWindowChild child1
Tab_1.TabPage_1.dw_1.GetChild( "status", child1)
child1.SetTransObject(SQLCA)
child1.setfilter(ls_filter)
child1.Filter()
child1.Retrieve()

4.  All values from the dddw table are present.  The initial record retrieved has a Status of "S" for Submitted and it renders fine (display shows Submitted).  First click on the dddw then changes the display to "S" and the filtered displays all show in the dddw including Submitted.  Also, removing the filter and doing an auto retrieve makes the dddw work fine.

James

Comment
  1. John Fauss
  2. Monday, 13 September 2021 21:43 PM UTC
I'm a little suspicious of performing the child1.Retrieve() after defining and applying the filter, Have you tried doing the Retrieve prior to the SetFilter or Filter calls?
  1. Helpful 1
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 13 September 2021 17:57 PM UTC
  2. PowerBuilder
  3. # 5

Hi, James - 

Can you please supply us with a little more information:

What is the datatype of the column (sounds maybe that it is "time")?

Can you include a snapshot of the column's Edit Properties tab page in the DW Painter?

Can you show us the code that constructs the child DW filter expression and issues the SetFilter function?

When the initial filter is applied to the child DW, is the column's data value included or excluded from the filtered rows in the child DW?

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