1. Pete Yankovich
  2. PowerBuilder
  3. Monday, 10 February 2020 20:14 PM UTC

Is it possible to change dddw child for a column based on other values in the row?

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 11 February 2020 15:16 PM UTC
  2. PowerBuilder
  3. # 1

Hi Pete,

the workaround depends on different things.

Is the datawindow for reporting or for editing?

Are there only a few and fixed number of different DDDW's or not?

 

1) If the datawindow is only for reporting you may think about not using DDDW's. You may read the display value from database with the datawindow data in one request.

 

2) If the datawindow is for editing you may choose to different column objects for the same column in the datawindow (have the column only one time in select but add it multiple times in dw painter!). So you can have a different DDDW for each column object and you may show/hide column objects dependend on the data in the row. But this is only usefull if the number of different DDDWs is not too much and not variable.

 

3) At least you may choose to have one column for editing and one dummy column for showing the display value (here you the dummy column in select!). Show the column for editing for the current row and the dummy column for all other rows. You have to transfer the display value for each row after retrieve (or on retrieve like in 1.) and if the value changes.

 

HTH,

René

Comment
There are no comments made yet.
Pete Yankovich Accepted Answer Pending Moderation
  1. Tuesday, 11 February 2020 14:03 PM UTC
  2. PowerBuilder
  3. # 2

Thanks Rene, my objective is to dynamically change the DDDW child for a column in a given row based on other values in the row.

Can you elaborate on the workarounds?

Pete

Comment
  1. Brad Mettee
  2. Tuesday, 11 February 2020 14:53 PM UTC
How many different DDDWs will there be? Too many would make harder, but not impossible.



I think the easiest solution would be multiple DDDWs column objects for the same column (copy/paste (or multiple adds of) the column, assign new name(s)), taking up the same space, using the visible attribute to show the appropriate one as needed. You can design with all the columns lined up side by side. Give them the same X position (hard coded override) so they all end up displayed in the same spot.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 11 February 2020 06:26 AM UTC
  2. PowerBuilder
  3. # 3

Hi Pete,

yes you can as Chris and Michael wrote.

But there is a limitation: The DDDW child for a column object is the same for all rows! If you want different childs for each row you have to deal with workarounds.

HTH,

René

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 10 February 2020 22:10 PM UTC
  2. PowerBuilder
  3. # 4

Yes, it is. Here is example of code to run just before DDDW is displayed. This code only spends time on changing DDDW and retrieving data when there is a need to change the DDDW. The code is generic so it could be added to a generic DataWindow class.

Also, it calls another event = ue_GetRelevantDDDW to know which DDDW object to use.

// USER EVENT  ue_DropDown
// MAPPED ID   pbm_DwnDropDown
// -----------------------------------------------------------------------------
long   row;        row = this.GetRow( )
string column;     column = this.GetColumnName()
string ls_newDDDW; ls_newDDDW = this.event ue_GetRelevantDDDW(row, column) //!!!
string ls_oldDDDW; ls_oldDDDW = this.Describe(column + ".DDDW.Name")

// Refresh DDDW only when needed
if ls_newDDDW <> ls_oldDDDW then
   // Change DDDW object
   this.Modify(column + ".DDDW.Name=" + ls_newDDDW)
   // Retrieve data for new DDDW
   DataWindowChild ldwc
   this.GetChild(column, ref ldwc)
   ldwc.SetTransObject(SQLCA)
   ldwc.Retrieve( )
end if

NOTE: There is no status code checks to capture or handle any errors!

Also, it doesn't handle DDDW objects using retrieval arguments.

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 10 February 2020 21:32 PM UTC
  2. PowerBuilder
  3. # 5

Hi Pete;

  Yes you can. The way I do it is ...

1) Export a current DDDW based parent DWO

2) Take note of the DDDW's property assignments

3) Use the Modify() command to replicate these assignments at run time.

   Just use a different DDDW object and column assignments as required.

HTH

Regards ... Chris

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.