Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid DynamicBackcolor property
Message
De
11/09/2005 04:14:47
 
 
À
11/09/2005 00:40:24
Aaron K. Y. Chu
Health & Care Co. Ltd.
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01048499
Message ID:
01048506
Vues:
21
>Dear All,
>
>Using Cetin's idea on dynamicBackcolor, I want to display the information in a grid where 2 backcolor alternated each other, such like single recno or double recno... however, this time is using the date, the records with same date using same backcolor...
>
>IN dynamicbackcolor of the grid
>
>Thisform.pf1.tx.SetAll("dynamicbackcolor","IIF(MOD(thisform.getbackcolor(ptt1.tx_date,'ptt1'),2)=0,RGB(212,237,218),RGB(255,255,255))", "Column")
>
>
>Custom Method: getbackcolor
>
>LPARAMETERS tdate, cTable
>
>DO CASE
>CASE cTable = 'ptt1'
>	SELECT RECNO('tmpvisit1') as a FROM tmpVisit1 INTO CURSOR tmp WHERE tx_date = tdate
>CASE cTable = 'ptt2'
>	SELECT RECNO('tmpvisit2') as a FROM tmpVisit2 INTO CURSOR tmp WHERE tx_date = tdate
>ENDCASE
>
>RETURN tmp.a
>
>
>tmpVisit1 is generated from the ptt1 as follows:
>
>SELECT distinct tx_date from ptt1 into cursor tmpVisit1 order by tx_date
>
>
>However, the backcolor is changing according to tx_date?! what's wrong? Please help

If you put the table where search ptt1.tx_date,
the code becomes simpler:
Thisform.pf1.tx.SetAll("dynamicbackcolor","IIF(MOD(thisform.getbackcolor(ptt1.tx_date,'tmpVisit1'),2)=0,RGB(212,237,218),RGB(255,255,255))", "Column")
You cannot use RECNO() with the parameter within a SQL Select,
because it use the datasession alias, not the SQL Select alias.
Another point is don't change the current workarea ( the grid alias ),
then uses a array:
LPARAMETERS tdate, cTable
PRIVATE tmp
SELECT RECNO() FROM (m.cTable) INTO ARRAY tmp WHERE tx_date = m.tdate
RETURN m.tmp
You should to have a index on tmpVisit1,
SELECT distinct tx_date from ptt1 into cursor tmpVisit1 && order by tx_date order is useless
INDEX ON tx_date TAG PK_DATE
and then this is 100x faster:
LPARAMETERS tdate, cTable
SEEK(M.tdate,m.cTable)
RETURN RECNO(m.cTable) 
and then you can remove the getbackcolor procedure:
Thisform.pf1.tx.SetAll("dynamicbackcolor";
,"IIF(MOD(IIF(SEEK(ptt1.tx_date,'tmpVisit1'),RECNO('tmpVisit1'),0),2)=0;
,RGB(212,237,218),RGB(255,255,255))", "Column")
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform