I have a xbrowse within a dialog , 12 value columns and a column containing the total ,
The 12 values can be edited , my xbrowse allows editing of these columns and i need to sum all columns
The columns are correctly shown
The last column can not be edited and i want it to be summed,
Adding a obrw:maketotals() to the update function produce a very strange result, the total column where the data is entered is doubled , editing the cell again without change , the column total is reset correctly. The last column is summed correctly in this case. Looks like the sum is evaluated twice ?
Removing the maketotals() from the update function, columns are correctly calculated but last column is not summed
I am using fwh 10.5
Any idea ?
- Code: Select all Expand view
REDEFINE XBROWSE oBrw ID 201 OF ODLG ;
COLUMNS "LIBELLE","PREV01","PREV02","PREV03","PREV04","PREV05","PREV06","PREV07","PREV08","PREV09","PREV10","PREV11","PREV12","TOTPREV" ;
HEADERS "Famille","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre","Total" ;
PICTURES nil, "@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99", "@Z 999 999 999.99", ;
"@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99" , "@Z 999 999 999.99", "@Z 999 999 999.99", "@Z 999 999 999.99" ;
COLORS {|| { CLR_BLUE, CLR_WHITE } } ;
ALIAS FUSER lines FOOTERS AUTOSORT
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:lColDividerComplete := .t.
oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:bClrHEADER := {|| { CLR_BLUE, COULDLG("TD") } }
oBrw:nFreeze := 1
oBrw:nCOLSEL := 2
AEVAL(oBrw:aCols, { |DLIB,X | SETCOLBRW(X,OBRW,FUSER,ASIZE) } )
oBrw:aCols[1]:cFooter := "Total"
ODLG:bSTART := { || OBRW:MAKETOTALS(),OBRW:SETFOCUS() }
STATIC FUNCTION SETCOLBRW(x,OBRW,FUSER,ASIZE)
oBrw:aCols[X]:nWidth := ASIZE[X]
IF X > 1
oBrw:aCols[X]:nFooterType := AGGR_TOTAL
IF X < 14
oBrw:aCols[X]:nEditType := 1
oBrw:aCols[x]:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, UPDPREV(v,OBRW,X,@FUSER), ) }
ENDIF
ENDIF
RETURN NIL
STATIC FUNCTION UPDPREV(DVAL,OBRW,NCOL,FUSER)
LOCAL ANCVAL := 0, ;
DT
DT := "PREV" + STRTRAN(STR(NCOL-1,2)," ","0")
ANCVAL := (FUSER)->&DT
LOCKENR(FUSER)
(FUSER)->&DT := DVAL
(FUSER)->TOTPREV += (DVal - ANCVAL)
(FUSER)->(DBUNLOCK())
// OBRW:MAKETOTALS() //if i uncomment this line , last column is summed but all other colums are doubled !!!
OBRW:REFRESH()
RETURN NIL