Page 1 of 1

xbrowse row colours

Posted: Mon Mar 02, 2020 10:37 pm
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

Re: xbrowse row colours

Posted: Mon Mar 02, 2020 11:26 pm
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

 

Re: xbrowse row colours

Posted: Tue Mar 03, 2020 6:11 am
by Iris Gesser
Thank you!

Re: xbrowse row colours

Posted: Tue Mar 03, 2020 8:55 pm
by Iris Gesser
I have just tried it, It worked perfectly, thank you, Cristobal!

Re: xbrowse row colours

Posted: Wed Mar 04, 2020 2:11 am
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
>