Is it possible to change dddw child for a column based on other values in the row?
Is it possible to change dddw child for a column based on other values in the row?
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é
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
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é
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.
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