Grid Values

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Grid Values

Post 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.
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Grid Values

Post 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"
have fun
Jimmy
User avatar
serge_girard
Posts: 3166
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid Values

Post 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
There's nothing you can do that can't be done...
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid Values

Post 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.
All The Best,
Franco
Canada
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid Values

Post 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
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Grid Values

Post 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
have fun
Jimmy
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid Values

Post 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.
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Grid Values

Post by AUGE_OHR »

hi Franco,

have you SET

Code: Select all

   SET BROWSESYNC ON                                                  // sync BROWSE with DBF
have fun
Jimmy
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid Values

Post 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
All The Best,
Franco
Canada
mlnr
Posts: 126
Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF

Re: Grid Values

Post 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};

Best regards,
Gabor
Post Reply