xBrowse sum help? (SOLVED)

xBrowse sum help? (SOLVED)

Postby Horizon » Mon Jun 20, 2022 9:57 am

Hi,

I want to sum one column in xbrowse. If I sum all of records, there is not any problem using below.

Image
Code: Select all  Expand view
if ! Empty( oCol := oBrw:oCol( "Ödeme Yeri" ) )
    oCol:nHeadStrAlign := AL_LEFT
    oCol:nDataStrAlign := AL_LEFT
    oCol:nWidth := 70
    oCol:bStrData:={|o| IIF((oBrw:cAlias)->OD_YERI="H","Havale","Büroda")} 
    oCol:cFooter := "Toplam"+CRLF+"Havale"+CRLF+"Büroda"
endif
 
if ! Empty( oCol := oBrw:oCol( "Tutar" ) )
    oCol:nWidth := 90
    oCol:nTotal      := 0
    oCol:lTotal      := .t.
endif

oBrw:lFooter := .T.
oBrw:nFooterLines := 3


But I want to sum "Havale", "Büroda" and "all" records in "Ödeme Yeri" like that


Code: Select all  Expand view
Toplam 700
Havale 225
Büroda 475


Any help?
Last edited by Horizon on Fri Jun 24, 2022 11:52 am, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: xBrowse sum help?

Postby nageswaragunupudi » Tue Jun 21, 2022 8:36 am

Code: Select all  Expand view
if ! Empty( oCol := oBrw:oCol( "Tutar" ) )
    oCol:nWidth := 90
   oCol:nFooterType := AGGR_SUM
//    oCol:nTotal      := 0
//    oCol:lTotal      := .t.
endif
 


and finally,
Code: Select all  Expand view
oBrw:MakeTotals()
oBrw:CreateFromCode()
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse sum help?

Postby Horizon » Tue Jun 21, 2022 8:51 am

Thank you Mr. Rao,

I have changed your advice but there is not any change.

As I said before, I should sum three condition. 1. all, 2. Header Ödeme Yeri = "Büroda", 3 - Header Ödeme Yeri = "Havale"

and I want to show three total in footer "Tutar" column.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: xBrowse sum help?

Postby nageswaragunupudi » Wed Jun 22, 2022 5:05 am

XBrowse does not natively support multiple totals in a single column.
We need to use workaround.

Please try this sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   USE CUSTOMER

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" ;
      COLUMNS "FIRST", "MARRIED", "SALARY", "SALARY AS SALU" ;
      COLSIZES 100,80,120 ;
      LINES NOBORDER FASTEDIT FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :nFooterLines  := 3
      :nEditTypes    := EDIT_GET

      WITH OBJECT :Married
         :SetCheck()
         :bFooter := { || "Total" + CRLF + "Married" + CRLF + "Unmarried" }
         :nFootStrAlign := AL_RIGHT
      END

      WITH OBJECT :Salary
         :cEditPicture  := "@E 999,999,999.99"
         :nFooterType   := AGGR_SUM
         :bSumCondition := { || oBrw:Married:Value }
         :bFooter := { |o| TRANSFORM( o:nTotal + oBrw:SalU:nTotal, o:cEditPicture ) + CRLF + ;
                           TRANSFORM( o:nTotal, o:cEditPicture ) + CRLF + ;
                           TRANSFORM( oBrw:SalU:nTotal, o:cEditPicture ) }
      END

      WITH OBJECT :SalU
         :nFooterType   := AGGR_SUM
         :bSumCondition := { || !oBrw:Married:Value }
         :lHide         := .t.
      END

      :MakeTotals()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   CLOSE CUSTOMER

return nil
 


Image

Please use similar logic in your program.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse sum help?

Postby Horizon » Fri Jun 24, 2022 11:52 am

nageswaragunupudi wrote:XBrowse does not natively support multiple totals in a single column.
We need to use workaround.

Please try this sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   USE CUSTOMER

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" ;
      COLUMNS "FIRST", "MARRIED", "SALARY", "SALARY AS SALU" ;
      COLSIZES 100,80,120 ;
      LINES NOBORDER FASTEDIT FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :nFooterLines  := 3
      :nEditTypes    := EDIT_GET

      WITH OBJECT :Married
         :SetCheck()
         :bFooter := { || "Total" + CRLF + "Married" + CRLF + "Unmarried" }
         :nFootStrAlign := AL_RIGHT
      END

      WITH OBJECT :Salary
         :cEditPicture  := "@E 999,999,999.99"
         :nFooterType   := AGGR_SUM
         :bSumCondition := { || oBrw:Married:Value }
         :bFooter := { |o| TRANSFORM( o:nTotal + oBrw:SalU:nTotal, o:cEditPicture ) + CRLF + ;
                           TRANSFORM( o:nTotal, o:cEditPicture ) + CRLF + ;
                           TRANSFORM( oBrw:SalU:nTotal, o:cEditPicture ) }
      END

      WITH OBJECT :SalU
         :nFooterType   := AGGR_SUM
         :bSumCondition := { || !oBrw:Married:Value }
         :lHide         := .t.
      END

      :MakeTotals()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   CLOSE CUSTOMER

return nil
 


Image

Please use similar logic in your program.


Thank you very much Mr. Rao. I have done like you described.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests