xbrowse row colours

Post Reply
User avatar
Iris Gesser
Posts: 38
Joined: Fri Apr 22, 2016 10:19 pm
Been thanked: 1 time

xbrowse row colours

Post by Iris Gesser »

Dear community,

I have tried to give a row another colour and it worked with this code.

oBrw:bClrStd := { || If( (cust->resstatus = "###Cancelled" .and. cust->guarancode = " "), { CLR_WHITE, CLR_RED }, { CLR_BLACK,CLR_WHITE } ) } //@IA 2020030

How can I integrate another colour for another request?
/* oBrw:bClrStd := { || If( ((cust->resstatus = "Waitlisted" .or. cust->resstatus = "Reserved" ).and. cust->guarancode = " "), ;
{ CLR_WHITE, CLR_GREEN }, { CLR_BLACK,CLR_WHITE } ) } //@IA 20200301*/

Do I have to use elseif in the oBrw:bClrStd?

If( (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ") --> backgroundcolur should be red
If( ((cust->resstatus = "Waitlisted" .or. cust->resstatus = "Reserved" ).and. cust->guarancode = " ") --> backgroundcolur should be green

Thank you in advance and kind regards
Iris
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: xbrowse row colours

Post by cnavarro »

Iris, if the condition to set the colors is very complicated, I advise you to use a function that returns the corresponding color array

Code: Select all | Expand


oBrw:bClrStd := { || MyColors( oBrw ) }
.../...

Function MyColors( oBrw )
    local aColors := { , }

   If (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ")
       aColors := { CLR_WHITE, CLR_RED }
   else
      if <other condition>
          aColors := { ....,  ..... }    etc.
      else
         aColors  := { CLR_BLACK,CLR_WHITE }
      endif
   endif
   .../...


Return aColors

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
Iris Gesser
Posts: 38
Joined: Fri Apr 22, 2016 10:19 pm
Been thanked: 1 time

Re: xbrowse row colours

Post by Iris Gesser »

Thank you!
User avatar
Iris Gesser
Posts: 38
Joined: Fri Apr 22, 2016 10:19 pm
Been thanked: 1 time

Re: xbrowse row colours

Post by Iris Gesser »

I have just tried it, It worked perfectly, thank you, Cristobal!
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: xbrowse row colours

Post by cnavarro »

Dear Iris, another way is to define the codeblock like this:

Extended literal code block.
Syntax
<| [<params,...>] | <programcode> >

Code: Select all | Expand


oBrw:bClrStd := <||
    local aColors := { , }

   If (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ")
       aColors := { CLR_WHITE, CLR_RED }
   else
      if <other condition>
          aColors := { ....,  ..... }    etc.
      else
         aColors  := { CLR_BLACK,CLR_WHITE }
      endif
   endif
   .../...
Return aColors
>
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Post Reply