Page 1 of 2

Grid Values

Posted: Mon Aug 08, 2022 4:03 pm
by franco
I am trying to set the dynamicbackcolor of grid when different items. I need the code to set a find of field value before grid.
I use this to black out day field divider rows in my scheduler program. This has to be set before window is set.

Code: Select all

Private bColor := { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2),{210,210,255}, {255,255,255})}     // THIS WORKS
Private bLcolor :=  { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2 .and. ThisCellValue = '"*"),{0,0,0}, {210,210,255})}  

WINDOW
DEFINE GRID
   DYNAMICBACKCOLOR{BCOLOR, BLCOLOR,BLCOLOR} //IF CELLVALUE (WHICH I DO NOT KNOW HOW TO SET BEFORE GRID) IS * 
ENDGRID                                                                   // BACKCOLOR IS BLACK OTHEWISE BACKCOLOR IS BLUE
END WINDOW

Thanks in advance.

Re: Grid Values

Posted: Mon Aug 08, 2022 11:43 pm
by AUGE_OHR
hi Franco,

as i can say DYNAMICBACKCOLOR will display when GRID "come up"

i do show different Color depend on Value of Field

Code: Select all

PRIVATE bColor    := { || IF( BLPRESS->DATAPPM >= nRangeMax, { 255, 0, 0 }, ;
                       IF( BLPRESS->DATAPPM >= nRange3, { 255, 64, 0 }, ;
                       IF( BLPRESS->DATAPPM >= nRange2, { 255, 128, 0 }, ;
                       IF( BLPRESS->DATAPPM >= nRange1, { 255, 192, 0 }, ;
                       IF( BLPRESS->DATAPPM >= nRangeMin, { 255, 255, 0 }, ;
                       IF( BLPRESS->DATAPPM >= nRangeMin - ( 50 / 3 ), ;
                       GREEN, PINK ) ) ) ) ) ) }
i do use Color only on Column 3-5

Code: Select all

DYNAMICBACKCOLOR { NIL, NIL, bColor, bColor, bColor, NIL }
---
when using Array you still have "CellValue"
This.CellRowIndex, This.CellColIndex and This.CellValue variables are available at codeblock evaluation.
so instead of "Field->xxx" you can use "This.CellValue"

Re: Grid Values

Posted: Tue Aug 09, 2022 6:07 am
by serge_girard
Franco,

I fill up my grid after window was created, then in GRID:

Code: Select all

         DYNAMICBACKCOLOR  { { || BC_Grid_BRS_SIS()}, {||BC_Grid_BRS_SIS()}, {||BC_Grid_BRS_SIS()}, ;                 

Code: Select all

STATIC FUNCTION BC_Grid_BRS_SIS
/*****************************/
LOCAL a
LOCAL aColors  := {{ HONEYDEW, HONEYDEW, HONEYDEW  } }  // EQUAL TO NUMBER OF COLUMNS == 48
LOCAL aItem    := Form_BROS_SIS.Grid_BRS_SIS.Item ( This.CellRowIndex )

DO CASE 
CASE ALLTRIM(aItem [3]) == 'P' 
   FOR a = 1 TO 3
      aColors [1] [a] := ORANGE
   NEXT a

OTHERWISE
   IF ALLTRIM(aItem [2]) == 'V' 
      FOR a = 1 TO 3
         aColors [1] [a] := MISTYROSE
      NEXT a
   ELSE
      FOR a = 1 TO 3
         aColors [1] [a] := LIGHTBLUE
      NEXT a

   ENDIF
ENDCASE

RETURN aColors [1] [ This.CellColIndex ]


Serge

Re: Grid Values

Posted: Tue Aug 09, 2022 7:27 pm
by franco
Thanks guys,
I tried these all morning. I think Jimmy`s would suit my needs better but can not get to work.
I will try again tomorrow and post a sample.

Re: Grid Values

Posted: Wed Aug 10, 2022 7:43 pm
by franco
I think these do not work because I am using a table not an array.
If you have time, add the following to 3.4.4\samples\controls\grid\grid38 maybe you will see what I mean.

Code: Select all

public bcolor := { || if( this.Cellrowindex/2 == int(this.CellRowIndex/2), {210,120,255}, {100,100,255})} //THIS WORKS
public bcolor :=   {|| if (This.CellValue = 1, {210,120,255}, {100,100,255})}           // THIS DOES NOT.
dynamicbackcolor{bcolor,bcolor,bcolor,bcolor,bcolor,bcolor}
Thanks, Franco

Re: Grid Values

Posted: Wed Aug 10, 2022 10:42 pm
by AUGE_OHR
hi,
franco wrote: Wed Aug 10, 2022 7:43 pm I think these do not work because I am using a table not an array.

Code: Select all

public bcolor :=   {|| if (This.CellValue = 1, {210,120,255}, {100,100,255})}           // THIS DOES NOT.
have you try

Code: Select all

public bcolor :=   {|| if (This.CellValue = "1"
GRID (WC_LISTVIEW) use only String "to Display" so you must use

Code: Select all

if (This.CellValue = String
---

when use a Table = DBF you should NOT use This.xxx but FIELD-> (or better ALIAS Name)

Code: Select all

 {|| IF( FIELD->NUMBER = nValue
or

Code: Select all

 {|| IF( FIELD->NAME = cValue

Re: Grid Values

Posted: Thu Aug 11, 2022 1:18 am
by franco
Still can not get to work. Have you tried it in folder and grid sample above.

Code: Select all

public bcolor :=   {|| if (field->first = 1, {210,120,255}, {100,100,255})} 
[/]
This will filter out first record.
If I change record 2 code to 1 it will filter out record 1 and 2, but does not change the colors.

Re: Grid Values

Posted: Thu Aug 11, 2022 7:08 am
by AUGE_OHR
hi Franco,

have you SET

Code: Select all

   SET BROWSESYNC ON                                                  // sync BROWSE with DBF

Re: Grid Values

Posted: Thu Aug 11, 2022 8:46 am
by franco
Browsesync is on
In grid38 all colors turn black. The only thing I can get working is if( This.CellRowIndex .

Code: Select all

public bcolor :=   {|| if (field->first = 1, {0,0,0}, {250,250,255})}     // whole grid is black
public bcolor := { || if( this.Cellrowindex/2 == int(this.CellRowIndex/2), {210,120,255}, {100,100,255})}            //THIS WORKS

Re: Grid Values

Posted: Thu Aug 11, 2022 9:55 am
by mlnr
Hi Franco,

Please, try this

Code: Select all

	
	public bcolor_1 :=   {|| if (This.CellValue = 1, {210,120,255}, {100,100,255})} 
	public bcolor  :=   { || {128,128,128} }
	
        dynamicbackcolor{bcolor_1,bcolor,bcolor,bcolor,bcolor,bcolor};