Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Background Color Expression in Grid Datawindow

959 views
Skip to first unread message

Jeromy_Van_Dusen

unread,
Jan 16, 2002, 5:26:42 PM1/16/02
to
This is driving me nuts. I need to highlight fields containing a certain
error condition in a grid datawindow. I also need to count those errors. I
can't use Modify to set the background color to highlight the field,
because that will highlight the whole column, whereas I need just the
column on a specific row to be highlighted. So, for every column that I may
need to highlight, I've created an additional column called
'columnname_flag' (ie. I have a column called 'owned', and a corresponding
'owned_flag' column). I have created a function which loops through all the
rows/columns looking for the error conditions, and sets the '_flag' column
to 'Y' or 'N' accordingly. Then, on the columns I want highlighted I have
set an expression for the Background.Color property that checks the '_flag'
column and sets the color accordingly. For example, the 'owned' column's
Background.Color expression is set to:

if( owned_flag = 'Y', 65535, 16777215 )

If I make the flag columns visible and editable, and I preview the
datawindow, I can set the '_flag' column to 'Y' or 'N' and see the
corresponding column change to yellow or white, just as it should. However,
when I run the application, the color never changes.

It would seem logical that the only difference between datawindow preview
and running the app is the code. So, I tried using an ordinary datawindow
(not inherited from anything) with no code in it whatsoever (other than a
SetTransObject and Retrieve), and it still didn't work. I've tried
everything I can think of. Other developers in the office have looked into
it and come up with nothing. Any ideas?

I'm using PB 6.5.1 with PFC on Win2KPro.

TIA

Jeromy Van Dusen

p

unread,
Jan 16, 2002, 7:16:16 PM1/16/02
to
Although I am not sure why it is not working, I wil make a suggestion for
implementaion.
Having flag column per column is probably overkill.
Make just one column (large string). In code set the value of this column
in each row to a delimited list of column names with errors. Set the
background.color expression condition to Match(...) on the column name.

P.S. I am not making this up on the fly, did something similar couple of
years ago...

p

unread,
Jan 16, 2002, 7:16:16 PM1/16/02
to

Alex Osin

unread,
Jan 16, 2002, 8:16:32 PM1/16/02
to
Jeromy .
Try to use expression for Background Color for column you need to highlight
ex: if( unit_price > 10,rgb(255,0,0),rgb(255,255,255))
HTH
Alex Osin

<Jeromy_Van_Dusen> wrote in message
news:6B26AC6A3047D5A8007B4B8185256B43.007B4BA285256B43@webforums...

aaa

unread,
Jan 16, 2002, 11:21:52 PM1/16/02
to
your column field maybe have a transparent background mode,change it to
0(Opaque) in the first

<Jeromy_Van_Dusen> wrote in message
news:6B26AC6A3047D5A8007B4B8185256B43.007B4BA285256B43@webforums...

Jeromy Van Dusen

unread,
Jan 17, 2002, 9:16:32 AM1/17/02
to
Alex,

I had originally tried something like that, however I ran into two problems.
First, it still didn't work -- the background color expression just got
ignored, as it does now. Secondly, I need to change the value in the field
as well. For example, if a char field retrieved from the database contains
only the value "*", it is an error and should be flagged. However, I don't
want the user to see the "*", only the highlighting. So, I'm changing the
value of that field to "", and setting the flag for the field so the
expression will cause the color to change. If the expression relies on the
actual value of the field, it will change back to the regular color as soon
as I remove the "*". I also need to be able to keep a running total of the
errors, so if I use code to check the value and update the flag, instead of
relying only on the datawindow expression, I can also use that same code to
update the error count.

Anyway, the larger problem is still that the background color expression is
getting completely ignored for reasons I cannot yet fathom. If I move that
expression to the color property, so that the foreground color will be
changed instead of the background color, it works. However I need the
background to change, not the foreground. Hence my frustration. :(

Thanks for the suggestion.

Jeromy

"Alex Osin" <alex...@hotmail.com> wrote in message
news:2RxLLVv...@forums.sybase.com...

Paul Horan[TeamSybase]

unread,
Jan 17, 2002, 10:24:49 AM1/17/02
to
Doing anything with SetRedraw()? You might try SetRedraw( FALSE ), <do all
your SetItems to the _flag columns>, SetRedraw( TRUE ).
That will force the datawindow to repaint. Since the _flag columns are not
visible at runtime, PB may be thinking it doesn't have to repaint the dw
after the SetItem calls...

Paul Horan[TeamSybase]
VCI Springfield, MA
www.vcisolutions.com

"Jeromy Van Dusen" <jvandusen@_SPAMFREE_online-can.com> wrote in message
news:hHJztI2...@forums.sybase.com...

Jeromy Van Dusen

unread,
Jan 17, 2002, 10:52:25 AM1/17/02
to
Paul,

That's something I had not thought of. However, I have now tried it and it
doesn't appear to make any difference. The thing that I find really odd is
that I can use the same expression on a different property (text color or
visible, for example), and it works fine. The moment I put that expression
on the background color property, it just gets ignored -- although it works
when previewing.

Here's something truly strange: The column objects all start with white
backgrounds. The expression sets them to yellow if the flag is set, and
white otherwise. If I change the column objects to start off as another
color, like blue, when I run the app they all appear as white. This would
suggest that the expression is being validated and coming up with the false
result, which changes the color to white. However, if I swap the expression
around so that it changes the color to white if the flag is set and yellow
otherwise, you would expect the column to always be yellow. But, run the
app, and all columns are STILL white. No matter what I do, the column
insists on being white. Now, this would suggest to me that there is code
hidden somewhere that is setting it white. With the exception of the PFC
code, all code in this entire application was written by me, and I am
positive there is no code elsewhere that is changing the background color.
In fact, I did a test yesterday where I used a regular datawindow (not
inherited from anything else) that contained ONLY a SetTransObject and
Retrieve, so I could be absolutely certain that no other code was being
executed that could possibly change the color, and it still didn't work.
How's that for strange?

Anyway, thanks for the suggestion.

Jeromy


"Paul Horan[TeamSybase]" <paulhATvcisolutionsDOTcom> wrote in message
news:ew1Yov2...@forums.sybase.com...

Wally

unread,
Jan 18, 2002, 7:02:43 PM1/18/02
to

My $.02

I've encounted problems like this which were fixed by calling dw_1.GroupCalc() appropriately.

jmho

0 new messages