PDA

View Full Version : Browse Row Color Changes When Value changes


ABC123

forskare
04-27-2008, 12:09 AM
Has anyone tried to format columns in a browse so that when a value changes, the, The font and row color changes. Example: A browse contains a list of names sorted alphabetically. I would like the font color and the cell color to change when the first letter of the last name changes.

Thanks for the ideas and suggestions.

ken

FWIW, we got another 15+" of snow last night and today, that's over 48 inces for the month of April. Ahhh Nutzzzz

MoGrace
04-27-2008, 12:17 AM
Has anyone tried to format columns in a browse so that when a value changes, the, The font and row color changes. Example: A browse contains a list of names sorted alphabetically. I would like the font color and the cell color to change when the first letter of the last name changes.

Thanks for the ideas and suggestions.

ken

FWIW, we got another 15+" of snow last night and today, that's over 48 inces for the month of April. Ahhh NutzzzzCan't help with your browse - but it was over 100 today!

forskare
04-27-2008, 12:19 AM
Can't help with your browse - but it was over 100 today!

Wow, that is HOT for LA this time of year. My Dad said it was 85 where he lives by the sand dunes in Arroyo Grande.

kenn

DaveM
04-27-2008, 12:57 AM
HaHa
Florida is real nice right now!

Nice and warm with a sweet breeze. In short sleeves and no sweat, just nice.

forskare
04-27-2008, 02:19 AM
HaHa
Florida is real nice right now!

Nice and warm with a sweet breeze. In short sleeves and no sweat, just nice.

Hey Dave, I have a shovel with your name on it :D !!

I believe I've found a solution. In the browse' Other Tab, select the colors and let the Genie create the code for the first 2, 3, or however many rows. Then convert the code, Copy and paste it to the end of the line until there is enough for the 26 letters of the alphabet. Finally, edit the code to reflect the change for each letter.

kenn

Tim Kiebert
04-27-2008, 02:24 AM
Has anyone tried to format columns in a browse so that when a value changes, the, The font and row color changes. Example: A browse contains a list of names sorted alphabetically. I would like the font color and the cell color to change when the first letter of the last name changes.

Thanks for the ideas and suggestions.

ken

FWIW, we got another 15+" of snow last night and today, that's over 48 inces for the month of April. Ahhh NutzzzzKen I was going to suggest similar but see you already have some thing. If you just want to alternate between two colors you could use an expression like - mod(asc(left(Lastname,1)),2)>0 - in just one line of the genie and change the default color to your choice.

DaveM
04-27-2008, 11:52 AM
Kenn,

I thought they dumped Min into canada because it was too cold and deep up there. You mean it is stiill part of the usa???

UH, I used a shovel once. bout 50 years ago and swore "never again".

Actually always got along with people from your state. Land of lakes??

forskare
04-27-2008, 02:50 PM
Ken I was going to suggest similar but see you already have some thing. If you just want to alternate between two colors you could use an expression like - mod(asc(left(Lastname,1)),2)>0 - in just one line of the genie and change the default color to your choice.

Hello Tim,

First, a recap. I opened the Column' Properties and put the following code in the Color Equeation box of the Other Tab:

case(left(Artist,len("A"))="A","Teal on Pale Yellow",left(Artist,len("B"))="B","Teal on #231,237,181",left(Artist,len("C"))="C","Teal on Pale Yellow",left(Artist,len("D"))="D","Teal on #231,237,181",left(Artist,len("E"))="E","Teal on Pale Yellow",left(Artist,len("F"))="F","Teal on #231,237,181",left(Artist,len("G"))="G","Teal on Pale Yellow",left(Artist,len("H"))="H","Teal on #231,237,181",left(Artist,len("I"))="I","Teal on Pale Yellow",left(Artist,len("J"))="J","Teal on #231,237,181",left(Artist,len("K"))="K","Teal on Pale Yellow",left(Artist,len("L"))="L","Teal on #231,237,181",left(Artist,len("M"))="M","Teal on Pale Yellow",left(Artist,len("N"))="N","Teal on #231,237,181",left(Artist,len("O"))="O","Teal on Pale Yellow",left(Artist,len("P"))="P","Teal on #231,237,181",left(Artist,len("Q"))="Q","Teal on Pale Yellow",left(Artist,len("R"))="R","Teal on #231,237,181",left(Artist,len("S"))="S","Teal on Pale Yellow",left(Artist,len("T"))="T","Teal on #231,237,181",left(Artist,len("U"))="U","Teal on Pale Yellow",left(Artist,len("V"))="V","Teal on #231,237,181",left(Artist,len("W"))="W","Teal on Pale Yellow",left(Artist,len("X"))="X","Teal on #231,237,181",left(Artist,len("Y"))="Y","Teal on Pale Yellow",left(Artist,len("Z"))="Z","Teal on #231,237,181",.T.,"black on white")

I generated the code by using the Genie to set the text abd backgroujnd color. To get the case parft of the expression, I created a query with the browse in View mode, to find all records where value in the Artist column begins with "A". Then, it was to simply put the query into code, copy the code and place it in the expression part of the Color Equation box. From there I easily did all 10 rows using the same code except for changing "A" to "B" to "C" to "D", etc in the remaining rows. That worked well.

OK, now I switched that to Xbasic, copied the necessary code and placed it almost at the end of the existing code amd made all the changes so all letters of the alphabet were represented. Finally, I copied to whole shootin' match and placed it in the Color Equation box of each column.

Did it work? Yes and No. The row colors should match in each row of every column. They do not; every column is different. When I looked at the code in each Color Equation box, the amount of code varies, even though I put the exact same code in each one. I replaced the code 3 times but as soon as I click the OK button to go from the expression builder back to properties a varied amount of code disappears.

Perhaps someone can take the code and test it on their own browse. I could include a zip but that won't necessarily confirm if it's me or a bug.

OK Tim, now for your suggestion. Would you be a bit more specific about where the code should be placed and how the color part is added to it?

Thanks again for the assistance.

kenn

G Gabriel
04-27-2008, 08:18 PM
Has anyone tried to format columns in a browse
Many times.


Example: A browse contains a list of names sorted alphabetically. I would like the font color and the cell color to change when the first letter of the last name changes

I normally do not respond to threads in v9, simply because I don't have it. But for Forsake's sakes and since the expression couldn't possibly be any different in the two versions, I am limiting my response here to the expression part.

First: I do not see how this color scheme will help you. If the last name starts with A, you will have Teal on pale yellow, if it starts with B, the next row will have a different color. Good.
But what if you have two rows the first has A and the next one has "C"? They will both have the same Teal on pale yellow .

But let's assume that all letters are always represented and that the row colors will alternate. Here comes the fun part:

I always find it amusing to see how alpha translates AS to an xbasic code, sometimes it looks moronic, but I do understand how everything is robotically engineered to fit the needs of the developer, any developer and all the developers.

For instance, look at this:
case(left(Artist,len("A"))="A",
!!
Seriously, do we need this extra function of len("A") ? don't we already know what len("A") is?
Again, at the end, you have: .t.,"black on white"
What are the chances of that happening? You already went through the whole alphabet. It could happen, if you are dealing with rap artists like 50 cents for instance, but is that the case? or are you dealing with Van Gogh and Michelangelo?

Now, what do you say if I tell you that this whole spaghetti of expression could be reduced to one short sentence?

MoGrace
04-27-2008, 08:27 PM
Gabe,
I know nobody asked me, but the first thing that came to my mind was:

And that sentence is ... ?

You would have made a good cat!

G Gabriel
04-27-2008, 08:34 PM
Wouldn't it be more fun, entertaing and more importantly, more educational, if you come up with it on your own? or have you given up that fast?

Tim Kiebert
04-27-2008, 08:50 PM
Hello Tim,

OK Tim, now for your suggestion. Would you be a bit more specific about where the code should be placed and how the color part is added to it?

Thanks again for the assistance.

kennKen,

Attached is a screen shot of the genie with the expression I posted.
Without using the genie the expression to enter directly in the equation field is

case(mod(asc(left(Lastname,1)),2)>0,"Teal on Pale Yellow",.T.,"Teal on #231,237,181")

MoGrace
04-27-2008, 08:52 PM
Actually, it is the use of the mod(), asc() stuff that gets me confused!

G Gabriel
04-27-2008, 08:54 PM
Allright, now the cat is out of the hat, here is that one short sentence expression:
"Teal on "+If(mod(asc(Artist ),2)=1,"Pale Yellow”,"#231,237,181")

forskare
04-27-2008, 11:44 PM
[CODE]First: I do not see how this color scheme will help you. [/QUOTE]

That's because you're assuming the browse will be used in the usual way. It won't. The browse is sorted alphabetically so all the A's are one color, B's another and so on. The browse willl be used for a visual effects as well as viewing the data.


But what if you have two rows the first has A and the next one has "C"? They will both have the same Teal on pale yellow.

Yeah, I thought about that and need to give it some thought. I suppose code could be written to insert a couple of rows and put text on it that says "No records for the letter "X"."


I always find it amusing to see how alpha translates AS to an xbasic code, sometimes it looks moronic, but I do understand how everything is robotically engineered to fit the needs of the developer, any developer and all the developers.

I should have removed the Black on White part of the code but Alpha did what it's programed to dochange AS to Xbasic.

what would I say if the code could be reduced to one short line? "COOL"

kenn

forskare
04-27-2008, 11:51 PM
Allright, now the cat is out of the hat, here is that one short sentence expression:
"Teal on "+If(mod(asc(Artist ),2)=1,"Pale Yellow”,"#231,237,181")

Hi Gabe,

I tried your code but Alpha says it is incomplete and will not save it.

Thank you for your efforts.

kenn

forskare
04-27-2008, 11:54 PM
Ken,

Attached is a screen shot of the genie with the expression I posted.
Without using the genie the expression to enter directly in the equation field is

case(mod(asc(left(Lastname,1)),2)>0,"Teal on Pale Yellow",.T.,"Teal on #231,237,181")


Hi Tim,

I tried your code and.......it works. Walla!

Thank you.

kenn

G Gabriel
04-28-2008, 12:04 AM
Works for me:
17134
My guess is your browse is based on a child table, in which case you need to modify the expression slightly to:
"Teal on "+if(mod(asc(child_table->artist),2)=1,"Pale Yellow","#231,237,181")

Tim Kiebert
04-28-2008, 12:38 AM
Hi Gabe,

I tried your code but Alpha says it is incomplete and will not save it.

Thank you for your efforts.

kennKen,

I think there is a format glitch between the forum text and alpha. ie using cut and paste. The code Gabe suggested should work. I tracked it down to the double quote after 'Yellow'. if you delete it and then retype the double quote it should work. If still not try retyping the whole thing.

I had not realized that asc() works on just the first character of the input so the Left() function is not necessary in my code.

G Gabriel
04-28-2008, 09:40 AM
First: I do not see how this color scheme will help you.
That's because you're assuming the browse will be used in the usual way. It won't. The browse is sorted alphabetically so all the A's are one color, B's another and so on. The browse willl be used for a visual effects as well as viewing the data.


I have actually made the assumption that the browse will be sorted as you say and that you want the visual impact of alternating colors and hence was my comment that it won't work if you have A's followed by C's for exapmle.

So the real question still remains, How do you sort a browse and have alternating colors when the sort value changers? Hmmmmm..

That's easy too. Hint:
I already did that in a different thread..but it was a long time ago!

forskare
04-30-2008, 07:06 PM
I have actually made the assumption that the browse will be sorted as you say and that you want the visual impact of alternating colors and hence was my comment that it won't work if you have A's followed by C's for exapmle.

So the real question still remains, How do you sort a browse and have alternating colors when the sort value changers? Hmmmmm..

That's easy too. Hint:
I already did that in a different thread..but it was a long time ago!

Hello Gabe,

Just so we're on the same page, what is your definition of: "a long time ago"?

forskare
04-30-2008, 07:07 PM
Ken,

I think there is a format glitch between the forum text and alpha. ie using cut and paste. The code Gabe suggested should work. I tracked it down to the double quote after 'Yellow'. if you delete it and then retype the double quote it should work. If still not try retyping the whole thing.

I had not realized that asc() works on just the first character of the input so the Left() function is not necessary in my code.

Hi Tim,

Yes, deleting the " and retyping it did the trick.

Thanks,

kenn

G Gabriel
04-30-2008, 07:20 PM
Ken:
I did something similar to that "a long while back" meaning sometime a year ago or earlier.. I don't quite remember what or how. Maybe a search will help rather than trying to re-invent the wheel..