We all eventually need to build a datawindow where the contents of a drop down list is dependent on the value of another column.
Filtering the available selections in the dddw for the current row is straight forward, just add the necessary filtering script in the RowFocusChanged and ItemChanged events. (See DDDW Contents Based on the Value of Another Column for more information regarding this. ) But if you have a tabular view, problems may soon become apparent with dependent columns in some rows displaying code values instead of descriptions.
- A Retrieve() is issued and the DDDW does not have a result set
- A row is Inserted
I have a dddw which hides certain items by setting the row height for these hidden rows to 0. This allows the column for other rows to still display the non-selectable dddw rows. But by using the arrow key or hotkeys (first letter of the description) the user can still select these rows which have a height of zero. Continue reading
The following example returns the display value for the dept_id column for the current row:
String ls_rownum., ls_return ls_rownum = String(dw_1.GetRow( )) ls_return = dw_1.Describe(“Evaluate(‘LookUpDisplay(dept_id)’,” + ls_rownum + “)”)
dw_parent.Modify(dept_id.dddw.name= d_dddw_empsal_by_dept )
ls_dddwname = idw_requestor.Describe(ls_columns[li_col] + “.dddwname”)
I had a window which had several columns which featured filtering and copying of dddw children data. After the datawindow refreshed its contents, this functionality no longer worked. I tracked this down to the fact that I was saving a reference to the dddw in an instance variable. Apparently, after the datawindow was refreshed, this reference was clobbered, and filtering or copying to this dddw resulted in an error. Oddly, another dddw reference was not clobbered. To solve this problem, I deleted the idwc and when I needed a reference to the dddw, I used a local variable.
Sometimes users want the oddest things.
I had an interesting requirement where the user wanted the same display value for two different data values. When the drop down appeared, additional columns were viewed which made it clear which data value should be associated to the display value. The problem was that if the display value does not change, the itemchanged is not triggered and the item status does not change to xxxModified!. This was very surprising and hard to track down.
The solution was to make the display value unique. This was done be appending many blank spaces and then the data value to the display value. The blank padding pushes the data value, which the user does not want to see, out of view
There is a PB bug (at least in 6.5, don’t know if was fixed in later versions) with filtering dddws. Sometimes, the filter buffer is discarded.
Use SetDetailHeight() to adjust the height of any rows in the dddw. Setting the height to zero will effectively remove the dddw item from view.
The hidden item still needs to be in the dddw so that the display value is shown on other rows. Note: the arrow key will allow the user to still select the hidden item. There is a superior way to hide dddw items which will be addressed in a later post.
//Do not allow the user to select Vacation from the dddw. // Vacation must be created through Employee Home Page ldwc_time_off_cd.SetRedraw(FALSE) dw_1.GetChild(“tm_off_cd”, ldwc_time_off_cd) ldwc_time_off_cd.SetFilter(“cd_id = 1001”) // filter out the non-vacation row, 1001 is code for vacation ldwc_time_off_cd.SetDetailHeight(1, ldwc_time_off_cd.RowCount(), 0) // hide the vacation row ldwc_time_off_cd.SetFilter(“”) ldwc_time_off_cd.Filter //Unfiliter all rows, only the non-vacation rows are visible ldwc_time_off_cd.SetRedraw(True)
In my app, if the user clicked on a new row for an updateable column, the dddw filter for pos_cd was not being applied. It would work if the user clicked on row outside any column, or on the pos_cd or rsrc_grp columns. Developed this workaround, added the following to the Clicked Event:
if IsValid(dwo) then if lower(dwo.type) <> "datawindow" then this.SetColumn('pos_cd' ) this.SetColumn('dpt_nbr' ) // first column end if if Lower(dwo.type) = "column" and row > 0 then ls_name = dwo.name this.SetColumn(ls_name) end if end if
integer li_col long ll_row ll_row = this.GetRow() if ll_row > 0 and this.RowCount() > 0 then wf_populate_resrc_grp_dropdown(ll_row) wf_FilterPositions() wf_ScrollToRow() li_col = this.GetColumn() if NOT IsNull(li_col) and li_col > 0 then this.SetColumn('pos_cd' ) this.SetColumn(li_col) end if end if
- 1. PowerBuilder General
- 2. Datawindows
- 3. PFC