Grid with more indexes
Posted: Mon May 10, 2010 1:16 pm
Hello,
I have problem with grid refresh for dbf file with more indexes.
Example:When first time I enter in test menue is ok . Then I sort grid with dbf to descending number (index 4) , grid is ok restorted to descending, then I go out with ESC to main menue and back to test. I get wrong grid ( see gridpic.jpg ).
Complete sources and pic in attached zip file.
#include "hmg.ch"
Function Main
REQUEST DBFNTX
RDDSETDEFAULT( "DBFNTX" )
SET DELETED ON
SET DATE GERMAN
SET CENTURY ON
SET EXCLUSIVE OFF
SET BROWSESYNC ON
SET LANGUAGE TO SLOVENIAN
SET NAVIGATION EXTENDED
REQUEST HB_CODEPAGE_SLWIN
HB_SETCODEPAGE( "SLWIN" )
Private bColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , { 245,245,245 } , { 255,255,255 } ) }
Private fColor := { || { 0,0,255 }}
DEFINE WINDOW meni ;
AT 20,20 ;
WIDTH getdesktopWidth()-50 ;
HEIGHT getDeskTopHeight()-120 ;
TITLE 'Test' ;
MAIN
DEFINE MAIN MENU
POPUP 'Menue'
ITEM '&1. Test' ACTION (test())
END POPUP
END MENU
END WINDOW
CENTER WINDOW meni
ACTIVATE WINDOW meni
close databases
return
procedure test
select 2
use naslovi alias naslovi
set index to naslovi,naziv
select 5
use gl_pred alias gl_pred
set index to gl_pred1,gl_pred2,gl_pred3,gl_pred4,gl_pred5
set relation to sifra into naslovi
go top
katerig:=reccount()
DEFINE WINDOW predrac ;
AT 20,20 ;
WIDTH getdesktopWidth()-50 ;
HEIGHT getDeskTopHeight()-120 ;
TITLE 'Test' ;
MODAL
@ 65,5 GRID Grid_pred ;
WIDTH getdesktopWidth()-70 ;
HEIGHT getDeskTopHeight()-270 ;
HEADERS { 'Num.','Šifra','Ime kupca','Datum','Znesek','Rabat','DDV','Zaslužek','Za plačilo',;
'Dod.stroški','Datum plačila','Valuta','Knjižen','Status','Plačano po','predračunu',;
'Vrsta','Zav.za davek'} ;
WIDTHS { 70,70,240,100,90,90,90,90,100,90,100,50,60,50,90,80,40,40 } ;
ROWSOURCE "GL_PRED" ;
VALUE { 1, 1} ;
COLUMNFIELDS { 'gl_pred->STEV','gl_pred->SIFRA','NASLOVI->NAZIV','gl_pred->DATUM','transform(round(gl_pred->vse,2),"@E 99,999,999.99")',;
'transform(round(gl_pred->rabat,2),"@E 9,999,999.99")','transform(round(gl_pred->davek,2),"@E 9,999,999.99")',;
'transform(round(gl_pred->prep,2),"@E 9,999,999.99")','transform(round(gl_pred->skupaj,2),"@E 9,999,999.99")',;
'transform(round(gl_pred->ptt,2),"@E 9,999,999.99")','gl_pred->DATUM_PLA','gl_pred->VALUTA','gl_pred->KNJ','gl_pred->STATUS',;
'transform(gl_pred->PLACANO,"@E 9,999,999.99")','gl_pred->PRED','substr(gl_pred->KON,2,1)', 'substr(naslovi->KOM2,46,1)' } ;
JUSTIFY { BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,;
BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,;
BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT };
TOOLTIP 'Seznam predračunov' ;
ON DBLCLICK test1() ;
FONT 'ARIAL' SIZE 10 ;
ON HEADCLICK { { || Sort_stevpred() },,, { || Sort_datpred() } } ;
HEADERIMAGES { '02.bmp','00.bmp','00.bmp','00.bmp' } ;
DYNAMICFORECOLOR { fColor,fColor,fColor,fColor,fColor,fColor,fcolor,fcolor;
,fColor,fColor,fColor,fColor,fcolor,fColor,fColor,fColor,fColor,fColor} ;
DYNAMICBACKCOLOR { bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,{|| if ( gl_pred->prep < 0 , {255,150,150} , {150,255,150} ) };
,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor };
LOCKCOLUMNS 5
ON KEY ESCAPE ACTION predrac.release
END WINDOW
CENTER WINDOW predrac
ACTIVATE WINDOW predrac
close databases
return
procedure sort_stevpred()
if indexord()=1
set order to 4
predrac.Grid_pred.HeaderImages( 1 ) := '01.bmp'
predrac.Grid_pred.HeaderImages( 4 ) := '00.bmp'
else
set order to 1
predrac.Grid_pred.HeaderImages( 1 ) := '02.bmp'
predrac.Grid_pred.HeaderImages( 4 ) := '00.bmp'
endif
predrac.Grid_pred.Refresh
return
procedure sort_datpred()
if indexord()=2
set order to 5
predrac.Grid_pred.HeaderImages( 4 ) := '01.bmp'
predrac.Grid_pred.HeaderImages( 1 ) := '00.bmp'
else
set order to 2
predrac.Grid_pred.HeaderImages( 4 ) := '02.bmp'
predrac.Grid_pred.HeaderImages( 1 ) := '00.bmp'
endif
predrac.Grid_pred.Refresh
return
procedure test1()
select naslovi
msginfo("test")
set deleted off
predrac.Grid_pred.recno:=10
set deleted on
return
best regards Rado
I have problem with grid refresh for dbf file with more indexes.
Example:When first time I enter in test menue is ok . Then I sort grid with dbf to descending number (index 4) , grid is ok restorted to descending, then I go out with ESC to main menue and back to test. I get wrong grid ( see gridpic.jpg ).
Complete sources and pic in attached zip file.
#include "hmg.ch"
Function Main
REQUEST DBFNTX
RDDSETDEFAULT( "DBFNTX" )
SET DELETED ON
SET DATE GERMAN
SET CENTURY ON
SET EXCLUSIVE OFF
SET BROWSESYNC ON
SET LANGUAGE TO SLOVENIAN
SET NAVIGATION EXTENDED
REQUEST HB_CODEPAGE_SLWIN
HB_SETCODEPAGE( "SLWIN" )
Private bColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , { 245,245,245 } , { 255,255,255 } ) }
Private fColor := { || { 0,0,255 }}
DEFINE WINDOW meni ;
AT 20,20 ;
WIDTH getdesktopWidth()-50 ;
HEIGHT getDeskTopHeight()-120 ;
TITLE 'Test' ;
MAIN
DEFINE MAIN MENU
POPUP 'Menue'
ITEM '&1. Test' ACTION (test())
END POPUP
END MENU
END WINDOW
CENTER WINDOW meni
ACTIVATE WINDOW meni
close databases
return
procedure test
select 2
use naslovi alias naslovi
set index to naslovi,naziv
select 5
use gl_pred alias gl_pred
set index to gl_pred1,gl_pred2,gl_pred3,gl_pred4,gl_pred5
set relation to sifra into naslovi
go top
katerig:=reccount()
DEFINE WINDOW predrac ;
AT 20,20 ;
WIDTH getdesktopWidth()-50 ;
HEIGHT getDeskTopHeight()-120 ;
TITLE 'Test' ;
MODAL
@ 65,5 GRID Grid_pred ;
WIDTH getdesktopWidth()-70 ;
HEIGHT getDeskTopHeight()-270 ;
HEADERS { 'Num.','Šifra','Ime kupca','Datum','Znesek','Rabat','DDV','Zaslužek','Za plačilo',;
'Dod.stroški','Datum plačila','Valuta','Knjižen','Status','Plačano po','predračunu',;
'Vrsta','Zav.za davek'} ;
WIDTHS { 70,70,240,100,90,90,90,90,100,90,100,50,60,50,90,80,40,40 } ;
ROWSOURCE "GL_PRED" ;
VALUE { 1, 1} ;
COLUMNFIELDS { 'gl_pred->STEV','gl_pred->SIFRA','NASLOVI->NAZIV','gl_pred->DATUM','transform(round(gl_pred->vse,2),"@E 99,999,999.99")',;
'transform(round(gl_pred->rabat,2),"@E 9,999,999.99")','transform(round(gl_pred->davek,2),"@E 9,999,999.99")',;
'transform(round(gl_pred->prep,2),"@E 9,999,999.99")','transform(round(gl_pred->skupaj,2),"@E 9,999,999.99")',;
'transform(round(gl_pred->ptt,2),"@E 9,999,999.99")','gl_pred->DATUM_PLA','gl_pred->VALUTA','gl_pred->KNJ','gl_pred->STATUS',;
'transform(gl_pred->PLACANO,"@E 9,999,999.99")','gl_pred->PRED','substr(gl_pred->KON,2,1)', 'substr(naslovi->KOM2,46,1)' } ;
JUSTIFY { BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,;
BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,;
BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_RIGHT };
TOOLTIP 'Seznam predračunov' ;
ON DBLCLICK test1() ;
FONT 'ARIAL' SIZE 10 ;
ON HEADCLICK { { || Sort_stevpred() },,, { || Sort_datpred() } } ;
HEADERIMAGES { '02.bmp','00.bmp','00.bmp','00.bmp' } ;
DYNAMICFORECOLOR { fColor,fColor,fColor,fColor,fColor,fColor,fcolor,fcolor;
,fColor,fColor,fColor,fColor,fcolor,fColor,fColor,fColor,fColor,fColor} ;
DYNAMICBACKCOLOR { bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,{|| if ( gl_pred->prep < 0 , {255,150,150} , {150,255,150} ) };
,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor,bcolor };
LOCKCOLUMNS 5
ON KEY ESCAPE ACTION predrac.release
END WINDOW
CENTER WINDOW predrac
ACTIVATE WINDOW predrac
close databases
return
procedure sort_stevpred()
if indexord()=1
set order to 4
predrac.Grid_pred.HeaderImages( 1 ) := '01.bmp'
predrac.Grid_pred.HeaderImages( 4 ) := '00.bmp'
else
set order to 1
predrac.Grid_pred.HeaderImages( 1 ) := '02.bmp'
predrac.Grid_pred.HeaderImages( 4 ) := '00.bmp'
endif
predrac.Grid_pred.Refresh
return
procedure sort_datpred()
if indexord()=2
set order to 5
predrac.Grid_pred.HeaderImages( 4 ) := '01.bmp'
predrac.Grid_pred.HeaderImages( 1 ) := '00.bmp'
else
set order to 2
predrac.Grid_pred.HeaderImages( 4 ) := '02.bmp'
predrac.Grid_pred.HeaderImages( 1 ) := '00.bmp'
endif
predrac.Grid_pred.Refresh
return
procedure test1()
select naslovi
msginfo("test")
set deleted off
predrac.Grid_pred.recno:=10
set deleted on
return
best regards Rado