1. Olan Knight
  2. PowerBuilder
  3. Monday, 16 August 2021 22:27 PM UTC

Update:  18-AUG-2021
   Here's one example of the expressions used in the various columns:

IF ( bg_color = 1, RGB (147, 233, 240),
      IF (bg_color = 2,  RGB (169, 228, 133),  
            IF (bg_color = 3, RGB (237, 192, 200), 553648127
                )
           )
     )

1 - Light blue  = currently processing
2 - light green = successful with no errors
3 - light red    = at least one error occurred
Else transparent

bg_column is a computed COLUMN (in the SQL) and set it with a dw.SetItem() command.

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

Update:  17-AUG-2021

It seems that the following code can READ data from the DW, but it cannot be used to WRITE data to the dw.
      ls_data = string (dw_1.Object.Data.Primary.Current[1,3])     // [Row 1, column 3]

This SLAYS me because I'm certain I was using a similar trick to write to the DW, but I've wasted enough time pursuing this already.  :/

I ended up adding a computed column called "bg_color" to the SQL, then an expression in the BackgroundColor property of the columns for which the background color was to change. Calling SetItem() to populate the bg_color did the trick.

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

PBv12.1, build 7055
Windows 10, 64 bit platform


Summary:
I can change the background color for ALL of the columns easilt.
What is the syntax for just updating one row?


Details:
This works for changing the background color for ALL of the rows:

// Get the specified color
CHOOSE CASE as_bgcolor        
    CASE "LIGHT BLUE"
        ll_color = RGB (147, 233, 240)            
    CASE "LIGHT GREEN"
        ll_color = 9764735            // RGB (169, 228, 133)
    CASE "LIGHT PINK"
        ll_color = RGB (237, 192, 200)    
    CASE ELSE    // "BUTTONFACE"
        ll_color = RGB (244, 244, 244)        
END CHOOSE


// The 10 displayed columns are:
ls_column [1]  = "bill_fccid"
ls_column [2]  = "ban"
....
ls_column [10] = "customer_group_uid"

// Init
ll_count = 10
ls_row   = string (al_row)
ls_cmd   = ""
ls_color = string (ll_color)

// Build the MODIFY command
FOR ll_idx = 1 TO ll_count

    ls_cmd = ls_cmd + " " + ls_column [ll_idx] + ".background.mode=0" +  &
                            " " + ls_column [ll_idx] + ".background.color=" + ls_color   

   // Change just one row - this syntax fails
//ls_cmd = ls_cmd + " " + &
//     ls_column [ll_idx] + "[" + string (al_row) + "].background.mode=0" +  &

// " "+ls_column [ll_idx] + "[" + string (al_row) + "].background.color=" + ls_color   
                            
NEXT    
                
//Change the background color
ls_status = dw_1.Modify (ls_cmd)

Shekar Reddy Accepted Answer Pending Moderation
  1. Thursday, 19 August 2021 01:27 AM UTC
  2. PowerBuilder
  3. # 1

You are prolly referring to Format attribute to apply colors to columns using square brackets like -

dw.Object."phone.Format = "[red](@@@)@@@-@@@@;'None'"

Or Display Format -

Positive-format;negative-format;zero-format;null-format

$#,##0.00;[RED]($#,##0.00)

Lookup Help for "Format property (DataWindow object)" or "Display formats"

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 18 August 2021 04:13 AM UTC
  2. PowerBuilder
  3. # 2

I think I understand why you experienced this issue, Olan...

Yes, you CAN read or write either a range of or individual data values via code like the example you gave:

ls_data = String(dw_1.Object.Data.Primary.Current[1,3]) // Read data value
dw_1.Object.Data.Primary.Current[1,3] = "foobar" // Write data value

but this notational convention cannot be used to access properties, it can only be used to access data values:

https://docs.appeon.com/pb2019r3/datawindow_reference/ch04s03.html

HTH, John

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 17 August 2021 18:12 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Olan -

Modify (or dot-notation), when applied to a column DWObject that resides in the detail band. affects that column object in all rows. I understand that's not the answer you want to hear, but that's the way it works. As Montgomery Scott (Scotty) is apt to say: "I canna change the laws of physics!".

To make a property change to one particular instance (row), you have to apply an expression to the column object's background color property. As I'm sure you're aware, the expression can utilize the column's data value, a dummy column's data value (as Roland suggested), a comparison involving the row number (as Shekar suggested), or it can use other creative techniques, you can even define or change the property's expression itself via Modify.

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 17 August 2021 17:39 PM UTC
  2. PowerBuilder
  3. # 4

While all of these suggestions are excellent, I just need to know the correct syntax to update a SINGLE column in a single row via the Modify command.

The reason is that various columns are going to have different colors within a single row.



I know I've DONE this a long time ago. I thought the syntax was to add a row in square brackets after the column name.

 

*Sigh*

 

 

Comment
  1. Miguel Leeuwe
  2. Wednesday, 18 August 2021 04:15 AM UTC
Hi Olan,

Yes, but ... probably you did that in an expression of the background color.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 18 August 2021 04:19 AM UTC
if you want to apply different colors to different columns in the same row, you'd have to add:

- different computed SELECT columns OR ..

- use something in the background color's expression that queries the column name: if think you can use "@col" to find out the column name: https://community.appeon.com/index.php/qna/q-a/find-out-column-name-in-an-expression

regards
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 17 August 2021 12:36 PM UTC
  2. PowerBuilder
  3. # 5

I would put a dummy column into the SQL that is the color number. The expression would set the color to the color column. Then in code you can use SetItem to control which row has the different color.

 

I have a colors example app that might be useful:

https://www.topwizprogramming.com/freecode_colors.html

 

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 17 August 2021 10:53 AM UTC
  2. PowerBuilder
  3. # 6

This will be good one for enhancement, IMO.

Comment
There are no comments made yet.
Shekar Reddy Accepted Answer Pending Moderation
  1. Tuesday, 17 August 2021 01:06 AM UTC
  2. PowerBuilder
  3. # 7

Without a dynamic expression for each row, setting color to any column affects all rows. You need to use a hidden flag Computed Column from SQL and fetch the value of the CC right through the SQL expressions (no need to set its value at runtime). Or set the value of the CC at runtime - you'll have to save the row-status before changing the value of CC and restore the row-status after setting its value for generic behavior if the CC's value is not computed inside SQL.

Some solutions in the order of what works better -

1. Assign the color expression of the Detail band based on the value the CC. This works better than #2 below as the color fills the entire row in the Detail band.

2) Use a row-wide Rectangle control inside DWO placed behind columns with whatever color you want and set its visibility based on the value of the CC. This works better than #3 below.

3) Set background color expressions of the columns based on the value of the CC.

If you want to color alternate rows for EZ-Read format (Zebra-striping), you could use a dynamic expression on the Detail band or Rectangle control (CC not needed). I usually use this format with a soft Blue and White alternate colors -

If( Mod( GetRow(), 2 ) = 0, RGB( 255, 255, 255 ), RGB( 232, 240, 255 ))

You could also use GetSysColor() function for system colors instead of RGB(). See GetSysColor() for color constants -

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor

HTH

PowerObject!

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.