Schultz’s PowerBuilder Notes

The Ol’ Hidden Items in the Dddw Problem Part II


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.

Continue reading

Advertisements

November 16, 2008 Posted by | Drop Down Data Window (DDDW) | , , , , , , , , , , , | 9 Comments

PFC DropdownDatawindow Search Service


The dropdowndatawindow search service enhances data entry into a dropdowndatawindow by automatically scrolling and filling in the field as a match is found on typed characters. It includes the following features:

Continue reading

July 2, 2008 Posted by | 3. PFC, Datawindow Services | , , , | Leave a comment

SetDetailHeight()


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)

May 12, 2008 Posted by | Drop Down Data Window (DDDW) | , , , , , , , , , | Leave a comment

Weird problem with dddw not applying filter when the user clicks on a different updateble column


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

RowFocusChanged

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 

May 10, 2008 Posted by | Drop Down Data Window (DDDW) | , , , , , , | Leave a comment

DDDW Contents Based on the Value of Another Column


The Problem

The contents of a particular drop down datawindow (dddw) depends on the value of another column. In the example, Version No is a drop down data window whose contents depend on the value of Tool Name. Version No will be a dddw child. Many books use retrieval arguments, but Andy Kempen showed me a way of using filter to avoid the additional database traffic. Note, this example assumes that the Code Value and the Display Value of the DDDW are the same. If they are different you will have another problem which will be addressed in another post

dddw-pic11

  • When the datawindow is retrieved, the entire contents of the dddw child must also be retrieved. In the ue_retrieve event:
// override ancestor

datawindowchild dwc
string          ls_tool_name

this.GetChild("version_no", dwc)
dwc.SetTransObject(SQLCA)
dwc.Retrieve( )

this.SetTransObject(SQLCA)
IF this.Retrieve(il_uo_seq_no) < 0 THEN
   IF SQLCA.SQLCode < 0 THEN
      MessageBox("&#91;1&#93;uo_dw@ue_retrieve",  SQLCA.SQLErrText, stopsign!)
   END IF
END IF

IF This.GetRow( ) = 0 THEN
   this.Event ue_insert( )
END IF&#91;/sourcecode&#93;
<ul>
	<li><!--&#91;if !supportLists&#93;--><span style="font-family:Symbol;"><span>I</span></span>f the user selects a different row, the column which drives the DDDW child may change, so the contents of the DDDW child will have to be updated.<span> </span>In the <strong>RowFocusChanged</strong> event:</li>
</ul>
datawindowchild  dwc
string           ls_tool_name

this.GetChild("version_no", dwc)
ls_tool_name = this.GetItemString ( currentrow, "tool_name" )
IF IsNull(ls_tool_name) THEN
   ls_tool_name = ""
END IF
dwc.SetFilter("tool_name = '" + ls_tool_name + "'" )
dwc.Filter( )

If the column which drives the DDDW child changes, the contents of the DDDW child will also have to change. So in the ItemChanged event:

datawindowchild dwc
string          ls_tool_name,ls_null

IsNull(ls_null)

IF Upper(getcolumnname( )) = "TOOL_NAME" THEN
   this.GetChild("version_no", dwc)
   ls_tool_name = data
   dwc.SetFilter("tool_name = '" + ls_tool_name +"'" )
   dwc.Filter( )
   SetItem(row, "version_no", ls_null)
end if
  • If a new row is inserted, the dwc should not have any rows as the tool_name column is empty. Script in the ue_insert event:
datawindowchild   dwc
decimal           ld_seq_num
integer           li_rc
string            ls_tool_name, ls_null

ld_seq_num = il_uo_seq_no
li_rc = this.SetItem ( this.GetRow( ), "SEQ_NO" , ld_seq_num )

IsNull(ls_null)
IF Upper(getcolumnname( )) = "TOOL_NAME" THEN
   this.GetChild("version_no", dwc)
   dwc.SetFilter("tool_name = '" + ls_null + "'" )
   dwc.Filter( )
END IF

May 10, 2008 Posted by | Drop Down Data Window (DDDW) | , , , , , , | 2 Comments