Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the color of the DW column

Status
Not open for further replies.

nik11

Programmer
Feb 6, 2010
34
0
0
US
I need to change the color of a datawindow field upon certain conditions. I put the condition in DW expression as well as in the code using modify statement but none of it is taking effect. Could anyone please tell me what could be the reason for this or is there any other way to implement this.
 
So you have the expression in the background color attribute of the column in the datawindow? or in some script as a modify statement?

Can you provide an example of what you have tried?

Matt

"Nature forges everything on the anvil of time
 
I had the following expression in the background color attribute of the column.
if(long(gettext())= abcd, 65535, 16777215)
where abcd is also a column of datatype long. When I run the application, this does not text effect but say if i just open the DW, retrieve it and make the changes, it works. Don't know why is it behaving like this.
The second way i tried using the modify statement. It didn't work either. But when i put the modify statement in the itemchanged event of the column, it started working.
Any thoughts Matt, why it didn't work by the first method.
 
I assume the GetText is the issue as this returns the text the user has entered in the current column. So it appears you are comparing the entered value in one column against the value in column 'abcd' and then changing the color right?

Matt

"Nature forges everything on the anvil of time
 
Yes, but it does not change the color when I run the application and make the changes.
 
why you are using gettext() instead of using the name of column only. exp in the expression you can use directly as if(xyz = abcd,876777,897777).It should workfine. Gettext() will create the issue in your context.
 
I am using gettext() because i want to compare with the value entered by the user. xyz is the value entered and not yet saved to the database.
 
I'm not sure if gettext() inside a column in a datawindow will result in what DATA would be inside the itemchanged event...

The explanation that it works after doing a normal retrieve() from the pb-ide might have something to do with the re-evalution of values in columns. For example by doing a sort() or a setredraw(true), values are re-evaluated.

1) Try to replace abcd with a fixed number in your expression and see what happens? Could it be your value of abcd is evaluated 'after' the expression?

2) I tried to reproduce your case: from the pb ide it does NOT work: pb 10.0.1, but from application execution it DOES!

I add an exported window and datawindow so you can import them and see what I mean:
(remember I'm using pb 10 not 11, you might have to modify the header of the exported files)

just copy the code and save it in two diferent text files, then import them into a library

Also, I'm not sure if you have to remove those 2 funny "ÿþ" characters before importing (unicode)...

datawindow start:
-----------------
ÿþ$ P B E x p o r t H e a d e r $ d w _ e x t _ t e s t . s r d

r e l e a s e 1 0 ;

d a t a w i n d o w ( u n i t s = 0 t i m e r _ i n t e r v a l = 0 c o l o r = 6 7 1 0 8 8 6 4 p r o c e s s i n g = 0 H T M L D W = n o p r i n t . p r i n t e r n a m e = " " p r i n t . d o c u m e n t n a m e = " " p r i n t . o r i e n t a t i o n = 0 p r i n t . m a r g i n . l e f t = 1 1 0 p r i n t . m a r g i n . r i g h t = 1 1 0 p r i n t . m a r g i n . t o p = 9 6 p r i n t . m a r g i n . b o t t o m = 9 6 p r i n t . p a p e r . s o u r c e = 0 p r i n t . p a p e r . s i z e = 0 p r i n t . c a n u s e d e f a u l t p r i n t e r = y e s p r i n t . p r o m p t = n o p r i n t . b u t t o n s = n o p r i n t . p r e v i e w . b u t t o n s = n o p r i n t . c l i p t e x t = n o p r i n t . o v e r r i d e p r i n t j o b = n o p r i n t . c o l l a t e = y e s h i d e g r a y l i n e = n o )

h e a d e r ( h e i g h t = 9 6 c o l o r = " 5 3 6 8 7 0 9 1 2 " )

s u m m a r y ( h e i g h t = 4 1 2 c o l o r = " 5 3 6 8 7 0 9 1 2 " )

f o o t e r ( h e i g h t = 0 c o l o r = " 5 3 6 8 7 0 9 1 2 " )

d e t a i l ( h e i g h t = 1 0 8 c o l o r = " 5 3 6 8 7 0 9 1 2 " h e i g h t . a u t o s i z e = y e s )

t a b l e ( c o l u m n = ( t y p e = c h a r ( 1 0 ) u p d a t e w h e r e c l a u s e = y e s n a m e = c o l u m n a _ a d b n a m e = " c o l u m n a _ a " )

c o l u m n = ( t y p e = c h a r ( 1 0 ) u p d a t e w h e r e c l a u s e = y e s n a m e = c o l u m n a _ b d b n a m e = " c o l u m n a _ b " )

)

t e x t ( b a n d = h e a d e r a l i g n m e n t = " 2 " t e x t = " C o l u m n a A " b o r d e r = " 6 " c o l o r = " 8 3 8 8 6 0 8 " x = " 3 5 2 " y = " 1 6 " h e i g h t = " 6 4 " w i d t h = " 2 8 3 " h t m l . v a l u e i s h t m l = " 0 " n a m e = c o l u m n a _ a _ t v i s i b l e = " 1 " f o n t . f a c e = " T a h o m a " f o n t . h e i g h t = " - 1 0 " f o n t . w e i g h t = " 4 0 0 " f o n t . f a m i l y = " 2 " f o n t . p i t c h = " 2 " f o n t . c h a r s e t = " 0 " b a c k g r o u n d . m o d e = " 1 " b a c k g r o u n d . c o l o r = " 5 3 6 8 7 0 9 1 2 " )

t e x t ( b a n d = h e a d e r a l i g n m e n t = " 2 " t e x t = " C o l u m n a B " b o r d e r = " 6 " c o l o r = " 8 3 8 8 6 0 8 " x = " 6 5 4 " y = " 2 0 " h e i g h t = " 6 8 " w i d t h = " 2 8 3 " h t m l . v a l u e i s h t m l = " 0 " n a m e = c o l u m n a _ b _ t v i s i b l e = " 1 " f o n t . f a c e = " T a h o m a " f o n t . h e i g h t = " - 1 0 " f o n t . w e i g h t = " 4 0 0 " f o n t . f a m i l y = " 2 " f o n t . p i t c h = " 2 " f o n t . c h a r s e t = " 0 " b a c k g r o u n d . m o d e = " 1 " b a c k g r o u n d . c o l o r = " 5 3 6 8 7 0 9 1 2 " )

c o l u m n ( b a n d = d e t a i l i d = 1 a l i g n m e n t = " 0 " t a b s e q u e n c e = 1 0 b o r d e r = " 5 " c o l o r = " 0 " x = " 3 5 2 " y = " 1 6 " h e i g h t = " 7 6 " w i d t h = " 2 7 4 " f o r m a t = " [ g e n e r a l ] " h t m l . v a l u e i s h t m l = " 0 " n a m e = c o l u m n a _ a v i s i b l e = " 1 " e d i t . l i m i t = 0 e d i t . c a s e = a n y e d i t . a u t o s e l e c t = y e s e d i t . a u t o h s c r o l l = y e s f o n t . f a c e = " T a h o m a " f o n t . h e i g h t = " - 1 0 " f o n t . w e i g h t = " 4 0 0 " f o n t . f a m i l y = " 2 " f o n t . p i t c h = " 2 " f o n t . c h a r s e t = " 0 " b a c k g r o u n d . m o d e = " 2 " b a c k g r o u n d . c o l o r = " 1 6 7 7 7 2 1 5 " )

c o l u m n ( b a n d = d e t a i l i d = 2 a l i g n m e n t = " 0 " t a b s e q u e n c e = 2 0 b o r d e r = " 5 " c o l o r = " 0 ~ t i f ( c o l u m n a _ a = ' 1 ' a n d l o n g ( g e t t e x t ( ) ) = 1 0 , r g b ( 2 5 5 , 0 , 0 ) , r g b ( 1 2 8 , 1 2 8 , 1 2 8 ) ) " x = " 6 5 8 " y = " 1 6 " h e i g h t = " 7 6 " w i d t h = " 2 7 4 " f o r m a t = " [ g e n e r a l ] " h t m l . v a l u e i s h t m l = " 0 " n a m e = c o l u m n a _ b v i s i b l e = " 1 " s l i d e u p = d i r e c t l y a b o v e e d i t . l i m i t = 0 e d i t . c a s e = a n y e d i t . a u t o s e l e c t = y e s e d i t . a u t o h s c r o l l = y e s f o n t . f a c e = " T a h o m a " f o n t . h e i g h t = " - 1 0 " f o n t . w e i g h t = " 4 0 0 " f o n t . f a m i l y = " 2 " f o n t . p i t c h = " 2 " f o n t . c h a r s e t = " 0 " b a c k g r o u n d . m o d e = " 2 " b a c k g r o u n d . c o l o r = " 1 6 7 7 7 2 1 5 " )

c o m p u t e ( b a n d = s u m m a r y a l i g n m e n t = " 0 " e x p r e s s i o n = " ~ " s u m a : ~ " + s u m ( l o n g ( c o l u m n a _ b ) ) " b o r d e r = " 0 " c o l o r = " 3 3 5 5 4 4 3 2 " x = " 5 2 6 " y = " 2 0 " h e i g h t = " 7 6 " w i d t h = " 8 6 4 " f o r m a t = " [ G e n e r a l ] " h t m l . v a l u e i s h t m l = " 0 " n a m e = c o m p u t e _ 1 v i s i b l e = " 1 " f o n t . f a c e = " T a h o m a " f o n t . h e i g h t = " - 1 2 " f o n t . w e i g h t = " 4 0 0 " f o n t . f a m i l y = " 2 " f o n t . p i t c h = " 2 " f o n t . c h a r s e t = " 0 " b a c k g r o u n d . m o d e = " 2 " b a c k g r o u n d . c o l o r = " 1 0 7 3 7 4 1 8 2 4 " )

h t m l t a b l e ( b o r d e r = " 1 " )

h t m l g e n ( c l i e n t e v e n t s = " 1 " c l i e n t v a l i d a t i o n = " 1 " c l i e n t c o m p u t e d f i e l d s = " 1 " c l i e n t f o r m a t t i n g = " 0 " c l i e n t s c r i p t a b l e = " 0 " g e n e r a t e j a v a s c r i p t = " 1 " e n c o d e s e l f l i n k a r g s = " 1 " n e t s c a p e l a y e r s = " 0 " )

x h t m l g e n ( ) c s s g e n ( s e s s i o n s p e c i f i c = " 0 " )

x m l g e n ( )

x s l t g e n ( )

j s g e n ( )

e x p o r t . x m l ( h e a d g r o u p s = " 1 " i n c l u d e w h i t e s p a c e = " 0 " m e t a d a t a t y p e = 0 s a v e m e t a d a t a = 0 )

i m p o r t . x m l ( )

e x p o r t . p d f ( m e t h o d = 0 d i s t i l l . c u s t o m p o s t s c r i p t = " 0 " x s l f o p . p r i n t = " 0 " )

e x p o r t . x h t m l ( )

/* -----------------
datawindow end:
----------------- */

window start:
-------------
ÿþ$ P B E x p o r t H e a d e r $ w _ t e s t _ m o d i f y _ x . s r w

f o r w a r d

g l o b a l t y p e w _ t e s t _ m o d i f y _ x f r o m w i n d o w

e n d t y p e

t y p e c b _ 2 f r o m c o m m a n d b u t t o n w i t h i n w _ t e s t _ m o d i f y _ x

e n d t y p e

t y p e c b _ 1 f r o m c o m m a n d b u t t o n w i t h i n w _ t e s t _ m o d i f y _ x

e n d t y p e

t y p e d w _ t e s t f r o m d a t a w i n d o w w i t h i n w _ t e s t _ m o d i f y _ x

e n d t y p e

e n d f o r w a r d



g l o b a l t y p e w _ t e s t _ m o d i f y _ x f r o m w i n d o w

i n t e g e r w i d t h = 3 1 6 8

i n t e g e r h e i g h t = 1 4 6 4

b o o l e a n t i t l e b a r = t r u e

s t r i n g t i t l e = " U n t i t l e d "

b o o l e a n c o n t r o l m e n u = t r u e

b o o l e a n m i n b o x = t r u e

b o o l e a n m a x b o x = t r u e

b o o l e a n r e s i z a b l e = t r u e

l o n g b a c k c o l o r = 6 7 1 0 8 8 6 4

s t r i n g i c o n = " A p p I c o n ! "

b o o l e a n c e n t e r = t r u e

c b _ 2 c b _ 2

c b _ 1 c b _ 1

d w _ t e s t d w _ t e s t

e n d t y p e

g l o b a l w _ t e s t _ m o d i f y _ x w _ t e s t _ m o d i f y _ x



o n w _ t e s t _ m o d i f y _ x . c r e a t e

t h i s . c b _ 2 = c r e a t e c b _ 2

t h i s . c b _ 1 = c r e a t e c b _ 1

t h i s . d w _ t e s t = c r e a t e d w _ t e s t

t h i s . C o n t r o l [ ] = { t h i s . c b _ 2 , &

t h i s . c b _ 1 , &

t h i s . d w _ t e s t }

e n d o n



o n w _ t e s t _ m o d i f y _ x . d e s t r o y

d e s t r o y ( t h i s . c b _ 2 )

d e s t r o y ( t h i s . c b _ 1 )

d e s t r o y ( t h i s . d w _ t e s t )

e n d o n



t y p e c b _ 2 f r o m c o m m a n d b u t t o n w i t h i n w _ t e s t _ m o d i f y _ x

i n t e g e r x = 1 5 7 3

i n t e g e r y = 1 2 1 6

i n t e g e r w i d t h = 4 0 2

i n t e g e r h e i g h t = 1 1 2

i n t e g e r t a b o r d e r = 2 0

i n t e g e r t e x t s i z e = - 1 0

i n t e g e r w e i g h t = 4 0 0

f o n t c h a r s e t f o n t c h a r s e t = a n s i !

f o n t p i t c h f o n t p i t c h = v a r i a b l e !

f o n t f a m i l y f o n t f a m i l y = s w i s s !

s t r i n g f a c e n a m e = " T a h o m a "

s t r i n g t e x t = " n o n e "

e n d t y p e



e v e n t c l i c k e d ; d w _ t e s t . i n s e r t r o w ( 0 )



e n d e v e n t



t y p e c b _ 1 f r o m c o m m a n d b u t t o n w i t h i n w _ t e s t _ m o d i f y _ x

i n t e g e r x = 1 1 3 4

i n t e g e r y = 1 2 1 6

i n t e g e r w i d t h = 4 0 2

i n t e g e r h e i g h t = 1 1 2

i n t e g e r t a b o r d e r = 2 0

i n t e g e r t e x t s i z e = - 1 0

i n t e g e r w e i g h t = 4 0 0

f o n t c h a r s e t f o n t c h a r s e t = a n s i !

f o n t p i t c h f o n t p i t c h = v a r i a b l e !

f o n t f a m i l y f o n t f a m i l y = s w i s s !

s t r i n g f a c e n a m e = " T a h o m a "

s t r i n g t e x t = " n o n e "

e n d t y p e



e v e n t c l i c k e d ; L O N G l _ x



l _ x = l o n g ( d w _ t e s t . d e s c r i b e ( " c o l u m n a _ b . x " ) )



l _ x = l _ x + 2 0



d w _ t e s t . m o d i f y ( " c o l u m n a _ b . x = " + s t r i n g ( l _ x ) )

d w _ t e s t . s e t R e d r a w ( t r u e )



e n d e v e n t



t y p e d w _ t e s t f r o m d a t a w i n d o w w i t h i n w _ t e s t _ m o d i f y _ x

i n t e g e r x = 2 1 9

i n t e g e r y = 1 2 8

i n t e g e r w i d t h = 2 5 6 0

i n t e g e r h e i g h t = 1 0 5 6

i n t e g e r t a b o r d e r = 1 0

s t r i n g d a t a o b j e c t = " d w _ e x t _ t e s t "

b o o l e a n h s c r o l l b a r = t r u e

b o o l e a n v s c r o l l b a r = t r u e

b o o l e a n l i v e s c r o l l = t r u e

b o r d e r s t y l e b o r d e r s t y l e = s t y l e l o w e r e d !

e n d t y p e



e v e n t c o n s t r u c t o r ; t h i s . i n s e r t r o w ( 0 )

t h i s . s e t c o l u m n ( ' c o l u m n a _ a ' )



e n d e v e n t

/* end window*/






regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top