xbrowse row colours

Post Reply
User avatar
Iris Gesser
Posts: 32
Joined: Fri Apr 22, 2016 10:19 pm

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: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

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

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Iris Gesser
Posts: 32
Joined: Fri Apr 22, 2016 10:19 pm

Re: xbrowse row colours

Post by Iris Gesser »

Thank you!
User avatar
Iris Gesser
Posts: 32
Joined: Fri Apr 22, 2016 10:19 pm

Re: xbrowse row colours

Post by Iris Gesser »

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

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

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
>
 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Post Reply