grid.setall("DynamicBackColor") question

grid.setall("DynamicBackColor") question

Post by Chris » Thu, 27 Apr 2000 04:00:00



I want to allow users to highlight rows in a grid if a particular field
value exists.  This is not a problem if i am allowing just ONE highlighting
option.  For example, in the SETALL code below, i let the user highlight
rows if the balance is greater than zero using an IIF:

thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
  "IIF(v_accounts.balance > 0, ;
  rgb(255,128,128),rgb(255,255,255))", ;
  "COLUMN")

But if i want to allow the user to highlight different sets of rows
("Balance exists"  OR  "ordered more than 30 days ago",   OR   "orders from
canada"), i need to leave any RGB setting as it was and not set it to white
as shown in the IIF example above, RGB(255,255,255).  I really need a case
statement of sorts:

CASE balance > 0
   RGB(n,n,n)
CASE orderdate < DATE()-30
   RGB(n,n,n)
CASE ordcountry = "CANADA"
   RGB(n,n,n)
OTHERWISE
   RGB(n,n,n)

How do i implement something like this using a SETALL (or perhaps not using
a SETALL) so that all three highlights can be in use at once?

TIA

 
 
 

grid.setall("DynamicBackColor") question

Post by Mark Croasdal » Thu, 27 Apr 2000 04:00:00


I am a FoxPro beginner so don't take this as gospel, but I have a similar requirement for one of my grids.

I have successfully put my DO CASE in a couple of functions SetForeCol() and SetBackCol() which are called from the Init method of the grid with:

THIS.SETALL("DynamicForeColor", "SetForeCol()", "Column")
THIS.SETALL("DynamicBackColor", "SetBackCol()", "Column")

This works well but has caused me an irritating problem.  The two functions test fields in a free table loaded by the Load() method of the form that contains the grid.  When I go to modify the form in the visual editor I get an alias not found message for each occurrence in the function.  I am fed up of clicking OK eight times!  Presumably, the Load method is executing as a prerequisite to the edit.  Anyone know how I can stop this happening?

Mark Croasdale
ICQ 21549408


> I want to allow users to highlight rows in a grid if a particular field
> value exists.  This is not a problem if i am allowing just ONE highlighting
> option.  For example, in the SETALL code below, i let the user highlight
> rows if the balance is greater than zero using an IIF:

> thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
>   "IIF(v_accounts.balance > 0, ;
>   rgb(255,128,128),rgb(255,255,255))", ;
>   "COLUMN")

> But if i want to allow the user to highlight different sets of rows
> ("Balance exists"  OR  "ordered more than 30 days ago",   OR   "orders from
> canada"), i need to leave any RGB setting as it was and not set it to white
> as shown in the IIF example above, RGB(255,255,255).  I really need a case
> statement of sorts:

> CASE balance > 0
>    RGB(n,n,n)
> CASE orderdate < DATE()-30
>    RGB(n,n,n)
> CASE ordcountry = "CANADA"
>    RGB(n,n,n)
> OTHERWISE
>    RGB(n,n,n)

> How do i implement something like this using a SETALL (or perhaps not using
> a SETALL) so that all three highlights can be in use at once?

> TIA


 
 
 

grid.setall("DynamicBackColor") question

Post by Zahid A. Al » Thu, 27 Apr 2000 04:00:00


IIF() functions can be nested. It isn't pretty, but you can issue:

thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
   "IIF(<Condition1>, <RGBExpr1>, ;
      IIF(<Condition2>, <RGBExpr2>, ;
         IIF(<Condition3>, <RGBExpr3>, ;
            <DefaultRGBExpr> ) ;
         ) ;
    )", ;
   "COLUMN")

You'll want to check my paren matching  :)
Zahid

Please doctor the e-mail address before replying.



Quote:> I want to allow users to highlight rows in a grid if a particular
field
> value exists.  This is not a problem if i am allowing just ONE
highlighting
> option.  For example, in the SETALL code below, i let the user
highlight
> rows if the balance is greater than zero using an IIF:

> thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
>   "IIF(v_accounts.balance > 0, ;
>   rgb(255,128,128),rgb(255,255,255))", ;
>   "COLUMN")

> But if i want to allow the user to highlight different sets of rows
> ("Balance exists"  OR  "ordered more than 30 days ago",
OR   "orders from
> canada"), i need to leave any RGB setting as it was and not set it to
white
> as shown in the IIF example above, RGB(255,255,255).  I really need a
case
> statement of sorts:

> CASE balance > 0
>    RGB(n,n,n)
> CASE orderdate < DATE()-30
>    RGB(n,n,n)
> CASE ordcountry = "CANADA"
>    RGB(n,n,n)
> OTHERWISE
>    RGB(n,n,n)

> How do i implement something like this using a SETALL (or perhaps not
using
> a SETALL) so that all three highlights can be in use at once?

> TIA

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

grid.setall("DynamicBackColor") question

Post by Gene Wirchen » Thu, 27 Apr 2000 04:00:00



>I want to allow users to highlight rows in a grid if a particular field
>value exists.  This is not a problem if i am allowing just ONE highlighting
>option.  For example, in the SETALL code below, i let the user highlight
>rows if the balance is greater than zero using an IIF:

>thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
>  "IIF(v_accounts.balance > 0, ;
>  rgb(255,128,128),rgb(255,255,255))", ;
>  "COLUMN")

>But if i want to allow the user to highlight different sets of rows
>("Balance exists"  OR  "ordered more than 30 days ago",   OR   "orders from
>canada"), i need to leave any RGB setting as it was and not set it to white
>as shown in the IIF example above, RGB(255,255,255).  I really need a case
>statement of sorts:

>CASE balance > 0
>   RGB(n,n,n)
>CASE orderdate < DATE()-30
>   RGB(n,n,n)
>CASE ordcountry = "CANADA"
>   RGB(n,n,n)
>OTHERWISE
>   RGB(n,n,n)

>How do i implement something like this using a SETALL (or perhaps not using
>a SETALL) so that all three highlights can be in use at once?

     I wrote a couple of procedures that might help.

********** Start of Included Code **********
* ion
* Interactive On
* Last Modification: 99-05-04
*
* The parameters are interpreted follows:
*   1) If no parameters, return .null..
*   2) Consider the value of parm01 against the succeeding pairs (2&3,
*      4&5, etc.)  If the value of parm01 = the first of the pair,
return
*      the second of the pair.
*   3) None of the pairs hit: if there is a parameter left over,
return it
*      else return .null..

procedure ion
lparameters parm1, parm2, parm3, parm4, parm5,;
 parm6, parm7, parm8, parm9, parm10,;
 parm11, parm12, parm13, parm14, parm15,;
 parm16, parm17, parm18, parm19, parm20,;
 parm21, parm22, parm23, parm24, parm25,;
 parm26, parm27

   local parmcount
   parmcount=pcount()

   if parmcount=0
      return .null.
      endif

   local parmptr, parmptrstr
   for parmptr=2 to parmcount-1 step 2
      parmptrstr=alltrim(str(parmptr))
      if (parm&parmptrstr)=parm1
         parmptrstr=alltrim(str(parmptr+1))
         return parm&parmptrstr
         endif
      endfor

   if parmcount%2=0
      parmptrstr=alltrim(str(parmcount))
      return parm&parmptrstr
   else
      return .null.
      endif

   endproc

* icase
* Interactive Case
* Last Modification: 98-12-17
*
* The parameters are interpreted follows:
*   1) If no parameters, return .null..
*   2) Consider each pair (1&2, 3&4, etc.).  If the first of the pair
is .t.,
*      return the second of the pair.
*   3) None of the pairs hit: if there is a parameter left over,
return it
*      else return .null..

procedure icase
lparameters parm1, parm2, parm3, parm4, parm5,;
 parm6, parm7, parm8, parm9, parm10,;
 parm11, parm12, parm13, parm14, parm15,;
 parm16, parm17, parm18, parm19, parm20,;
 parm21, parm22, parm23, parm24, parm25,;
 parm26, parm27

   local parmcount
   parmcount=pcount()

   if parmcount==0
      return .null.
      endif

   local parmptr, parmptrstr
   for parmptr=1 to parmcount-1 step 2
      parmptrstr=alltrim(str(parmptr))
      if parm&parmptrstr
         parmptrstr=alltrim(str(parmptr+1))
         return parm&parmptrstr
         endif
      endfor

   if parmcount%2==0
      return .null.
   else
      parmptrstr=alltrim(str(parmcount))
      return parm&parmptrstr
      endif

   endproc
********** End of Included Code **********

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.

 
 
 

grid.setall("DynamicBackColor") question

Post by Tim Witor » Thu, 27 Apr 2000 04:00:00



> I am a FoxPro beginner so don't take this as gospel, but I have a similar requirement for one of my grids.

> I have successfully put my DO CASE in a couple of functions SetForeCol() and SetBackCol() which are called from the Init method of the grid with:

> THIS.SETALL("DynamicForeColor", "SetForeCol()", "Column")
> THIS.SETALL("DynamicBackColor", "SetBackCol()", "Column")

> This works well but has caused me an irritating problem.  The two
> functions test fields in a free table loaded by the Load() method
> of the form that contains the grid.  When I go to modify the form
> in the visual editor I get an alias not found message for each
> occurrence in the function.  I am fed up of clicking OK eight times!  
> Presumably, the Load method is executing as a prerequisite to the edit.  
> Anyone know how I can stop this happening?

Funny (and little known) fact: when you are editing your form
in the form editor, VFP is actually running your form!  Obviously
it is not being run the same way as it is when you click the
Run button yourself, but it is running.  This is why you cannot
open up and edit a class that is on a form that is being edited.
You get the "Class is in use" error.  This error means that the
class is running.

All of this to explain why you are getting those errors.

One way to avoid it is to put the required tables in the DE,
but you must have a reason for not doing that, eh?  (you *can*
put free table in the DE, by the way)  Another way is to
replace the call to SetForeCol with in-line code that is
equivalent.  Usually an IIF() or nested IIF()s do the trick.

-- TRW
_______________________________________
My e-mail:  t r w 7

_______________________________________

 
 
 

grid.setall("DynamicBackColor") question

Post by Anders Altber » Fri, 28 Apr 2000 04:00:00


Which color do you choose form a Canadian client with balance > 0?
If the grid is based on a cursor from a view you can include two extra
numerical field and insert the rgb values that fit the case.
CREATE CURSOR colors (backcol I, forecol I)
INSERT INTO colors VALUES (RGB(255,255,255), 0)
CREATE VIEW myview AS SELECT * FROM mytable JOIN colors ON .T.  ...
THe two Integer fields will be added to myview with the default colors.
REPLACE backcol WITH RBG(128,64,255) ,forcol With 0  FOR Balance > 0
REPLACE backcol WITH RBG(255,0,0) ,forcol With  16711680  FOR country =
"Canada"
This.SetAll('dynamicbackcolor', 'myview.backcol','column')
This.SetAll('dynamicforecolor', 'myview.forcol','column')
This allows a wide range of settings and is fast.
Or  This.setall('dynamicbackcolor','RAND()*100000','column') for a real
sparkling effect ;)
You can test the effect in a browse window
 browse name xxx
 xxx.setall('dynamicbackcolor','rand()*10000000','column')

-Anders


I am a FoxPro beginner so don't take this as gospel, but I have a similar
requirement for one of my grids.

I have successfully put my DO CASE in a couple of functions SetForeCol() and
SetBackCol() which are called from the Init method of the grid with:

THIS.SETALL("DynamicForeColor", "SetForeCol()", "Column")
THIS.SETALL("DynamicBackColor", "SetBackCol()", "Column")

This works well but has caused me an irritating problem.  The two functions
test fields in a free table loaded by the Load() method of the form that
contains the grid.  When I go to modify the form in the visual editor I get
an alias not found message for each occurrence in the function.  I am fed up
of clicking OK eight times!  Presumably, the Load method is executing as a
prerequisite to the edit.  Anyone know how I can stop this happening?

Mark Croasdale
ICQ 21549408


Quote:> I want to allow users to highlight rows in a grid if a particular field
> value exists.  This is not a problem if i am allowing just ONE
highlighting
> option.  For example, in the SETALL code below, i let the user highlight
> rows if the balance is greater than zero using an IIF:

> thisform.pgfpagerefresh1.page1.grdnav.setall("DynamicBackColor", ;
>   "IIF(v_accounts.balance > 0, ;
>   rgb(255,128,128),rgb(255,255,255))", ;
>   "COLUMN")

> But if i want to allow the user to highlight different sets of rows
> ("Balance exists"  OR  "ordered more than 30 days ago",   OR   "orders
from
> canada"), i need to leave any RGB setting as it was and not set it to
white
> as shown in the IIF example above, RGB(255,255,255).  I really need a case
> statement of sorts:

> CASE balance > 0
>    RGB(n,n,n)
> CASE orderdate < DATE()-30
>    RGB(n,n,n)
> CASE ordcountry = "CANADA"
>    RGB(n,n,n)
> OTHERWISE
>    RGB(n,n,n)

> How do i implement something like this using a SETALL (or perhaps not
using
> a SETALL) so that all three highlights can be in use at once?

> TIA

 
 
 

grid.setall("DynamicBackColor") question

Post by Tim Witor » Fri, 28 Apr 2000 04:00:00



> Or  This.setall('dynamicbackcolor','RAND()*100000','column') for a real
> sparkling effect ;)
> You can test the effect in a browse window
>  browse name xxx
>  xxx.setall('dynamicbackcolor','rand()*10000000','column')

> -Anders

Congratulations, Anders.  You have just invented the most
nauseating user interface option with the fewest possible
lines of code!  I think everyone should drop that into
their grids and have it automatically activated on
April 1 every year.

-- TRW
_______________________________________
My e-mail:  t r w 7

_______________________________________

 
 
 

grid.setall("DynamicBackColor") question

Post by Anders Altber » Fri, 28 Apr 2000 04:00:00


I'll take that as a compliment. Very dynamic.
-Anders



> > Or  This.setall('dynamicbackcolor','RAND()*100000','column') for a real
> > sparkling effect ;)
> > You can test the effect in a browse window
> >  browse name xxx
> >  xxx.setall('dynamicbackcolor','rand()*10000000','column')

> > -Anders

> Congratulations, Anders.  You have just invented the most
> nauseating user interface option with the fewest possible
> lines of code!  I think everyone should drop that into
> their grids and have it automatically activated on
> April 1 every year.

> -- TRW
> _______________________________________
> My e-mail:  t r w 7

> _______________________________________

 
 
 

grid.setall("DynamicBackColor") question

Post by Tim Witor » Sat, 29 Apr 2000 04:00:00


That is how it was intended.  I appreciate compact, understandable,
and effective code.  Your code brilliantly makes any grid look
like Walt Disney puked on it.  Nice work. :^)  :^P

-- TRW


> I'll take that as a compliment. Very dynamic.
> -Anders




> > > Or  This.setall('dynamicbackcolor','RAND()*100000','column') for a real
> > > sparkling effect ;)
> > > You can test the effect in a browse window
> > >  browse name xxx
> > >  xxx.setall('dynamicbackcolor','rand()*10000000','column')

> > > -Anders

> > Congratulations, Anders.  You have just invented the most
> > nauseating user interface option with the fewest possible
> > lines of code!  I think everyone should drop that into
> > their grids and have it automatically activated on
> > April 1 every year.

> > -- TRW
> > _______________________________________
> > My e-mail:  t r w 7

> > _______________________________________

_______________________________________
 
 
 

grid.setall("DynamicBackColor") question

Post by Anders Altber » Sat, 29 Apr 2000 04:00:00


ROFL
-A


> That is how it was intended.  I appreciate compact, understandable,
> and effective code.  Your code brilliantly makes any grid look
> like Walt Disney puked on it.  Nice work. :^)  :^P

> -- TRW


> > I'll take that as a compliment. Very dynamic.
> > -Anders




> > > > Or  This.setall('dynamicbackcolor','RAND()*100000','column') for a
real
> > > > sparkling effect ;)
> > > > You can test the effect in a browse window
> > > >  browse name xxx
> > > >  xxx.setall('dynamicbackcolor','rand()*10000000','column')

> > > > -Anders

> > > Congratulations, Anders.  You have just invented the most
> > > nauseating user interface option with the fewest possible
> > > lines of code!  I think everyone should drop that into
> > > their grids and have it automatically activated on
> > > April 1 every year.

> > > -- TRW
> > > _______________________________________
> > > My e-mail:  t r w 7

> > > _______________________________________

> _______________________________________

 
 
 

grid.setall("DynamicBackColor") question

Post by Gene Wirchen » Tue, 02 May 2000 04:00:00



>That is how it was intended.  I appreciate compact, understandable,
>and effective code.  Your code brilliantly makes any grid look
>like Walt Disney puked on it.  Nice work. :^)  :^P

     <FX: sniff> The expression he used for colours really ought to
have been rand*16777216.

[snipped previous]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.

 
 
 

1. "SetAll" Property Question

Hi,

I have various controls on a Form - TextBoxes, Comboboxes, Spinners
etc.  I used the following command in the Init Event of the Form :

THIS.SetAll("ReadOnly", .T.)

It seems that only the TextBox controls have become ReadOnly.  To make
the other controls ReadOnly, I had to enter commands separately for
each type of control.  Is this a correct thing to do?  Why don't ALL
the Controls get the effect of the above command??

Also, my ComboBox's dont seem to accept the
THIS.SetAll("ReadOnly",.T.,"Combobox") command.  The Control doesn't
turn ReadOnly.  The RowSourceType of the Combobox is "3 - SQL
Statement".

Thanks in advance.

Regards,
Derek

2. GNU g++ / PRO*C / AIX need help configuring

3. max of ("...","...","..")

4. how to configure two Oracle Instance in Listener.ora

5. Data Grid "How to Subtotal Columns"

6. Run time error 3464

7. The "grid tool of choice"

8. Best Pratices

9. "Depopulate" a grid without requery

10. DBGrid "Grid Index Out of Range"

11. "Grid index out of range" nightmares

12. "Find" in db grid

13. "Grid index out of range" nightmares