1. Sivaprakash BKR
  2. PowerBuilder
  3. Wednesday, 12 September 2018 11:32 AM UTC

Hello,

Will changing the background color of a field, having dddw, affects data retrieved in the dddw ?

I got a dw with a field that got drop-down-datawindow [dddw].  I write code in edit changed [typeahead] even for easy selection of data from that dddw.   This was working perfect until I introduced a code to change the background color of fields that gets focus, in itemfocuschanged event.

After this Modify line in ItemfocusChanged event to change the background color, rows in dddw becomes zero when queried in editchanged event.

Commenting the backgroundcolour code in ItemFocusChanged event makes everything to work perfect.

Any solution to make it to work with back ground color settings ?

 

Happiness Always
BKR Sivaprakash

 

Olan Knight Accepted Answer Pending Moderation
  1. Friday, 14 September 2018 15:10 PM UTC
  2. PowerBuilder
  3. # 1

I've NO idea why the connection to the dddw gets lost, but the quick fix is to add thjis code in the EditChanged event:

   // Ensure the pointer to the dddw is valid
   ll_result = this.GetChild (is_column_focus, ddw_city)
   IF (ll_result > 0) THEN
      ll_result = ddw_city.SetTransObject (sqlca)
   END IF

That will force the pointer to the correct dddw.

Remember: if it's stupid but it works, it's not stupid.


Olan

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 12 September 2018 21:02 PM UTC
  2. PowerBuilder
  3. # 2

If I understand the issue correctly, the fix is to add the following code immediately after the last MODIFY call in the ItemFocusChanged event.

~~~~~~~~~~~~~~~~~~~~~~

// iddw_city should be an instance variable, set to the dddw in the appropriate column in the Constructor event of the DW control.


   is_save_colour = THIS.Describe (is_column_focus + &
     ".Background.Color")                       // Save curr. Colour
     
   This.Modify (is_column_focus + ".Background.Color='" + &
       String(f_get_focus_color ()) + "'")              // Set Focus colour!
   
   // Ensure the pointer to the dddw is valid
   ll_result = this.GetChild (is_column_focus, ddw_city)
   IF (ll_result > 0) THEN
      ll_result = ddw_city.SetTransObject (sqlca)
   END IF


   ls_select  = THIS.Describe (is_column_focus +  ".Edit.AutoSelect")         // Get AutoSelect property
   If Lower (ls_select) = "yes" THEN                    // Was it ON?
    THIS.selecttext (1, 99999)                       // YES=>Select it again!
   End If


Later -

Olan

Comment
  1. Sivaprakash BKR
  2. Friday, 14 September 2018 02:54 AM UTC
Thanks Olan

Unfortunately it didn't work out. Adding your code, we could assign the child, check with no of rows, in itemfocuschanged event. In editchanged, the rows retrieved is still zero.

Any other suggestions ?



Btw, why changing backgroundcolor affects these data ? Is it a bug ?

  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Wednesday, 12 September 2018 14:29 PM UTC
  2. PowerBuilder
  3. # 3

Thanks Johan Fauss for your swift reply.    Here are the details.

One Window   - [w_bkcolor]
One DataWindow  - [dw_bkcolor]
One DropDownDataWindow - [ddw_city]

Datawindow contains three fields, two edit fields and one field with dddw

dw_1 control in the window got codes in 2 events. 
        Itemfocuschanged &
        EditChanged


// ********************************************************

Code in ItemFocusChanged   // Got from STD-FC framework


String  ls_object                          // Object Var.
String  ls_type                          // Work Var.
String  ls_select                          // Work Var.
If ib_focus_colour = TRUE  THEN                     // Focus Colour ON?
 If LEN (is_column_focus) = 0 THEN                    // YES, Previous Focus?
  ls_object  = THIS.GetColumnName ( )                 //  Get 1st Focus Column
  If Len (ls_object) > 0 THEN                      // Valid Coloumn?
   
   is_column_focus = 'STD-FC-DUMMY'                  // NO=> Save "Dummy"
   ls_type = THIS.Describe (ls_object + ".Edit.Required")             //  Get Status
   If Lower (ls_type) = "yes" THEN                    // Required?
    is_save_colour = THIS.Describe (ls_object + &
       ".Background.Color")                     // YES=>Save it's colour!
   End If
   
   ls_type = THIS.Describe (ls_object + ".EditMask.Required")           // Get 2nd Type
   If Lower (ls_type) = "yes" THEN                    // Mask Requierd?
    is_save_colour = THIS.Describe (ls_object + &
      ".Background.Color")                     // YES=>Save it's colour!
   End If
   
   ls_type = THIS.Describe (ls_object + ".DDDW.Required")            // Get 3rd Type
   If Lower (ls_type) = "yes" THEN                    // Mask Requierd?
    is_save_colour = THIS.Describe (ls_object + &
      ".Background.Color")                     // YES=>Save it's colour!
   End If
   
   ls_type = THIS.Describe (ls_object + ".DDLB.Required")             // Get 4th Type
   If Lower (ls_type) = "yes" THEN                    // Mask Requierd?
    is_save_colour = THIS.Describe (ls_object + &
      ".Background.Color")                     // YES=>Save it's colour!
   End If
  End If
  This.Post Event itemfocuschanged (row, dwo)
  Return
 End If
 If is_column_focus <> DWO.Name THEN                 // Same Column?
  ls_type = THIS.Describe ( DWO.Name + ".Type")               // NO=>Get Obj. type
  If ls_type = 'column' THEN                       // Column?
   THIS.Modify (is_column_focus + ".Background.Color='" + &
        is_save_colour + "'")                    // YES=>Restore Colour
        
   is_column_focus = DWO.Name                     //  Save curr. col.
   
   is_save_colour = THIS.Describe (is_column_focus + &
     ".Background.Color")                       // Save curr. Colour
     
//   This.Modify (is_column_focus + ".Background.Color='" + &
//       String(f_get_focus_color ()) + "'")              // Set Focus colour!
   
   ls_select  = THIS.Describe (is_column_focus +  ".Edit.AutoSelect")         // Get AutoSelect property
   If Lower (ls_select) = "yes" THEN                    // Was it ON?
    THIS.selecttext (1, 99999)                       // YES=>Select it again!
   End If
  End If
 End If
End If

// ***************************************

 

// Code in editchanged
//*********************************************


If dwo.name = 'city' Then
 datawindowchild dw
 If dwo.name = 'city' Then
  dw = dwc1
 End If
 
 integer li_searchtextlen 
 long  ll_findrow
 string  ls_dddw_displaycol
 string  ls_foundtext
 string  ls_findexp
 string  ls_searchcolname
 long  ll_dddw_rowcount
 long  li_ddlb_index=0
 string  ls_displaydata_value
 string  ls_searchtext
 ls_searchcolname = dwo.Name
 ls_searchtext        = data
 li_searchtextlen     = Len (ls_searchtext)
 
 If (li_searchtextlen < Len(is_textprev)) or (Lower (ls_searchtext) = Lower (is_textprev)) Then
  is_textprev = ''
  Return
 End If
 is_textprev = ls_searchtext
 ls_dddw_displaycol = dwo.dddw.displaycolumn
 ls_findexp = "Lower (Left (" + ls_dddw_displaycol + ", " + String (li_searchtextlen) + ")) = '" + Lower (ls_searchtext) + "'"
 ll_dddw_rowcount = dw.rowcount()
 ll_findrow = dw.Find (ls_findexp, 0, ll_dddw_rowcount)
 ib_matchfound = (ll_findrow > 0)
 
 if ib_matchfound then
  ls_foundtext = dw.GetItemString (ll_findrow, ls_dddw_displaycol)
 Else
  is_textprev = ''
  This.SetText('')
 End If        
 If ib_matchfound Then
  This.SetText (ls_foundtext)
  if li_searchtextlen = len(ls_foundtext) THEN
   This.SelectText (Len (ls_foundtext)+1, 0)
  else
   This.SelectText (li_searchtextlen + 1, Len (ls_foundtext))
  end if
 End If
End If
// ********************************************************
 
With the above codes, 
When I type in City column, edit changed codes doesn't search values [ typeahead ]
 
When I comment out 2 lines in ItemFocusChanged  [ Line No. 51 & 52 ]
//   This.Modify (is_column_focus + ".Background.Color='" + &
//       String(f_get_focus_color ()) + "'")              // Set Focus colour!

Everything works fine.

 

I've attached a sample application [with the above code only] demonstrating this issue as a rar file. [using PB 2017 R3].

Happiness Always
BKR Sivaprakash

 

 

Attachments (1)
Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 12 September 2018 13:19 PM UTC
  2. PowerBuilder
  3. # 4

You should be able to change the background color of a child DataWindow without issue.

However, changes to a child DataWindow typically invalidates any DataWindowChild references you may have to the child DataWindow. If you change the Background color either through Modify() or dot-notation, you need to perform a GetChild to obtain a valid reference to the child DataWindow.

Since you did not include any of your code in your question, I cannot be sure this is what is happening in your case, but this is something you need to check.

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.