Schultz’s PowerBuilder Notes

Working with DDDW Properties


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 + “)”)


Another Example:

astr_parms.s_worker_nm = dw_1.Describe(“Evaluate(LookUpDisplay(day2_off_wrkr_id)’, 1”)

One more example

s_res_nm = dw_res_grp.Describe("Evaluate('LookUpDisplay(res_grp_id) ', 1)" )
ls_pos_nm = dw_pos.Describe("Evaluate('LookUpDisplay(pos_rsrc_id) ', 1)" )
ls_pos_nm = ls_res_nm + " / " + ls_pos_nm

In the ItemChanged event, I want to Reject the value of a column with a DDDW and allow the focus to change. But Return 2 does not seem to work.

Return 2 is changing the column item back to the original value, but the Display Item does not change. The DataWindow has rejected the value, but it is still displaying the changed value. Here is script which deals with this problem:

ItemChanged event:

Integer li_rc

If data<> is_normal_trade_on_shift then
   li_rc = MessageBox(“Warning”, “~”” + istr_emp.trade_off_shift + &
                ‘”shift normally trades with “’ + is_normal_trade_on_shift + ‘” shift “, &
                Information!, OkCancel!, 1)
   If li_rc = 2 then // reject the value, allow focus to change
      This.event Post ue_refresh_display()
      Return 2
   End if
End if

Wf_EmployeeFilter(data)
Wf_ShiftOrLocationChange()

Return 0

Ue_RefreshDisplay event:

String ls_shift

ls_shift = this.GetItemString(1, “shft_cd”)
This.SetItem(1, “shft_cd”, ls_shift)

How do I dynamically change a dddw properties?

Peter Louis wrote an interesting user object for holding a simple datawindow with two colums, one for string, the other for a long. This function sets the dw and its associated dddw for either the String column or the long column. The column not being used is turned invisible.

/////////////////////////////////////////////////////////////////////
//
//Event/Function: of_set_datawindow
/
//Access:          Public
//
//Arguments:        al_data_type  {Use the “Long” or “String” column}
//                  as_dw             (The name of the dddw)
//                  as_data_col    (The id  column of the dddw)
//                  as_display_col (The display  column of the dddw)
//                  ab_filter_required
//                  as_err_msg
//
//Returns:          true if successful.
//
//Description:    sets the datawindow.
//
//////////////////////////////////////////////////////////////////////
//
//   Revision History
//
// date      by   Comment
// --------  ---  ----------------------------------------------------
// 08/26/02  pl    Created.
//////////////////////////////////////////////////////////////////////

boolean lb_return = true
string  ls_result, ls_filter
datawindowchild ldwc

if al_data_type = icl_datatype_string then
   is_column = "string"
   is_data_col = as_data_col
   dw_generic.Modify("long.visible = 0" )
elseif al_data_type = icl_datatype_long then
   is_column = "long"
   is_data_col = as_data_col
   dw_generic.Modify("string.visible = 0" )
else
   as_err_msg = "of_set_datawindow: The specified data type is not supported."
   lb_return = false
end if

if lb_return then
   is_display_col = as_display_col
   is_dw_object = as_dw

   dw_generic.InsertRow(0)
   dw_generic.SetItem(1, "enabled", 1)

   // static style
   dw_generic.Modify(is_column + ".dddw.Required=No" )
   dw_generic.Modify(is_column + ".dddw.AllowEdit=No" )
   dw_generic.Modify(is_column + ".dddw.Line=10" )
   dw_generic.Modify(is_column + ".dddw.ShowList=No" )
   dw_generic.Modify(is_column + ".dddw.UseAsBorder=Yes" )
   dw_generic.Modify(is_column + ".dddw.VScrollBar=Yes" )

   ls_result = dw_generic.Modify(is_column + ".dddw.name = '" + is_dw_object + "'" )

   if ls_result <> "" then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to set the dddw.name: " + ls_result
   end if
end if

if lb_return then
   ls_result = dw_generic.Modify(is_column + ".dddw.datacolumn = '" + is_data_col + "'" )

   if ls_result <> "" then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to set the dddw.datacolumn:  " + ls_result
   end if
end if

if lb_return then
   ls_result = dw_generic.Modify(is_column + ".dddw.displaycolumn  = '" + is_display_col + "'" )

   if ls_result <> "" then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to set the dddw.displaycolumn:  " + ls_result
   end if
end if

if lb_return then
   dw_generic.GetChild(is_column, ldwc)

   if not IsValid(ldwc) then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to obtain the child datawindow."
   end if
end if

if lb_return then
   if ldwc.SetTransObject(SQLCA) <> 1 then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to set the transaction object."
   end if
end if

if lb_return then
   if ldwc.Retrieve() = -1 then
      lb_return = false
      as_err_msg = "of_set_datawindow: Failed to retrieve the child datawindow."
   end if
end if

if lb_return then
   if ab_filter_required then
      ib_filter_required = true

      ls_filter = is_data_col + " <> " + is_data_col

      if ldwc.SetFilter(ls_filter) = -1 then
         lb_return = false
         as_err_msg = "of_set_datawindow: Failed to set filter string."
      end if

      if lb_return then
         if ldwc.Filter() = -1 then
            lb_return = false
            as_err_msg = "of_set_datawindow: Failed to filter the dddw."
         end if
      end if
   end if
end if

return lb_return

Dot Notation

ls_data = dw_bd_job.Object.bd_tp_cd.dddw.lines
MessageBox("", ls_data)

dw_bd_job.Object.bd_tp_cd.dddw.lines = 5

What are the DDDW properties?

  • AllowEdit
  • AutoHScroll
  • Case
  • DataColumn
  • DisplayColumn
  • HScrollBar
  • HSplitScroll
  • Limit
  • Line
  • Name
  • NilIsNull
  • PercentWidth
  • Required
  • ShowList
  • UseAsBorder
Advertisements

May 13, 2008 - Posted by | Drop Down Data Window (DDDW), Powerscript | , , , , , , , , , , , , , ,

1 Comment »

  1. Hello,

    Thanks for the site. It has alot of helpful info.

    This is sort-of related, I am trying to modify a graph that is on a composite datawindow. Is there any way to do this?

    I’ve tried to get the datawindow containing the graph using getchild(). This gives me a DataWindowChild upon which I can only execute Modify() commands as it does not support going after the graph (gr_1) directly, nor does it support SetSeriesStyle(). Unfortunately, something as easy as setting the series color is not possible (at least I couldn’t figure out how) in either the painter or using a Modify() command.

    Do you have any ideas?

    Thanks in advance.

    Comment by Gord Cross | August 31, 2009 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: