Page 1 of 1

To Mr. Rao, XBrowse totals (SOLVED)

Posted: Wed Nov 11, 2020 7:24 pm
by Armando
Hi Mr. Rao:

Would you help us?

This is my code

Code: Select all

   REDEFINE XBROWSE oBrw ID 200 OF oDlg;
      DATASOURCE oRsDsl ;
      COLUMNS "DIE_FOL", "DIE_FDM", "DIE_REF", "", "","DIE_IMP","UNI_DES","OPE_NOM","DIE_DES", "DIE_CAN";
      HEADERS "Folio", "Fecha", "Referencia", "Compras", "Consumos","Importe","Unidad","Operador", "Destino(s)", "Can";
      COLSIZES 60, 75, 90, 65, 65, 80, 200, 220,230, 40, 40;
      PICTURES "@Z 9999999","dd/mmm/yyyy", NIL, "@Z 999,999", "@Z 999,999","@Z 9,999,999.99", NIL, NIL,NIL, NIL;
      JUSTIFY { AL_RIGHT, AL_RIGHT, AL_LEFT, AL_RIGHT, AL_RIGHT,AL_RIGHT, AL_LEFT, AL_LEFT, AL_LEFT, AL_CENTER };
      FOOTERS AUTOSORT BACKGROUND "Lineas"

   WITH OBJECT oBrw
      :l2007            := ( .F. )
      :lHScroll         := ( .F. )
      :lVScroll         := ( .F. )
      :nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :nStretchCol      := STRETCHCOL_LAST
      :SetGroupHeader( "L I T R O S", 04, 05 )
      :nHeaderHeight    := 25
      :nRowHeight       := 22
      :nFooterHeight    := 25
      :bClrHeader       := {|| { CLR_WHITE,CLR_BLACK } }
      :bClrFooter       := {|| { CLR_WHITE,CLR_BLACK } }
      :bClrSel          := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0,{ CLR_BLACK, oApp:nRowParClr }, { CLR_BLACK, oApp:nRowNonClr } ) }
      :bClrSelFocus     := {|| { oApp:nFClrFocus,oApp:nBClrFocus } }
      :bClrStd          := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0,{ CLR_BLACK, oApp:nRowParClr }, { CLR_BLACK, oApp:nRowNonClr } ) }
      :nRecSelColor     := oApp:nRowParClr
      :lDisplayZeros    := ( .F. )  // zero values are not displayed. Added by GNRao. No need to use @Z

      // Por fuerza debe ir dentro del WITH OBJECT oBrw
      WITH OBJECT :aCols[ 01 ]
         :cOrder := "A"
      END

      WITH OBJECT :aCols[ 04 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "E", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 05 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "S", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 06 ]
         :nFooterType      := AGGR_SUM
         :bSumCondition    := { || ! oRsDsl:Fields("DIE_CAN"):Value }
         :cFooterPicture   := "@Z 99,999,999.99"
         :nFootStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[07]
         :nFootStrAlign  := AL_LEFT
         :bFooter        := { || "<= no se incluyen los vales cancelados" }
      END

      :MakeTotals()

      WITH OBJECT :aCols[ 10 ]
         :SetCheck( { "SI16", "NO16" } )
      END
   END
 
As you can see there is one FIELD (oRsDsl:Fields( "DIE_LTS" ):Value) for two columns (4 and 5)
it depends on the field oRsDsl:Fields( "DIE_EOS" ):Value.
how can I get totals for each column (4 and 5)

I've tried with

Code: Select all

         :nFooterType      := AGGR_SUM
         :bSumCondition    := { || ! oRsDsl:Fields("DIE_CAN"):Value}
         :cFooterPicture   := "@Z 99,999,999.99"
         :nFootStrAlign    := AL_RIGHT
 
There is no error, but it does not work.

Best regards

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 1:35 pm
by Marco Augusto
no hará falta el
:lfooter := .T.

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 1:43 pm
by Armando
Hola Marco:

Que gusto saber de ti !

No, creo que no hace falta, tengo otra columna con totales y esos los pinta bien.

Ante el beneficio de la duda agregue esa línea y sigue sin funcionar.

Saludos

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 2:21 pm
by FranciscoA
Armando, intentalo asi: (cols 4,5)

Code: Select all

WITH OBJECT :aCols[ 05 ]
         :bEditValue := {|| IF( oRsDsl:RecordCount() > 0 .AND.   oRsDsl:Fields( "DIE_EOS" ):Value == "E",   oRsDsl:Fields( "DIE_LTS" ):Value, Space( 01 ) ) }
         :nFooterType      := AGGR_SUM
      END
Saludos.

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 2:42 pm
by Armando
Francisco:

Excelente, ya me da los totales pero... no me respeta el picture del footer, solo para esa columna,
son enteros y le agrega dos decimales y no separa los cientos.

:cFooterPicture := "@Z 99,999"

Saludos y muy agradecido

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 2:55 pm
by FranciscoA

Code: Select all

:bEditValue := {|| IF( oRsDsl:RecordCount() > 0 .AND.   oRsDsl:Fields( "DIE_EOS" ):Value == "E",   oRsDsl:Fields( "DIE_LTS" ):Value, 0 ) }

Re: To Mr. Rao, XBrowse totals

Posted: Thu Nov 12, 2020 2:59 pm
by Armando
Francisco:

Excelente, Ahora todo va bien.

Saludos

Re: To Mr. Rao, XBrowse totals (SOLVED)

Posted: Sun Nov 15, 2020 4:02 pm
by nageswaragunupudi
COLUMNS clause accepts both field names and also expressions.
Please try:

Code: Select all

COLUMNS "DIE_FOL", "DIE_FDM", "DIE_REF", ;
        "IF(DIE_EOS=='E',DIE_LTS,0)", "IF(DIE_EOS=='S',DIE_LTS,0)",;
        "DIE_IMP","UNI_DES","OPE_NOM","DIE_DES", "DIE_CAN";
 
and remove completely:

Code: Select all

/*
      WITH OBJECT :aCols[ 04 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "E", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 05 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "S", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END
*/
 
You may now add:

Code: Select all

:aCols[ 4 ]:nFooterType := AGGR_SUM
:aCols[ 5 ]:nFooterType := AGGR_SUM
 
Notes:
bStrData: Please never use bStrData. This data is deprecated years back. Instead use bEditValue and cEditPicture.
bStrData returns a character value. We can not expect XBrowse to total character values.

Alignment: XBrowse automatically aligns numeric and date values to right and other values to left. We need not specify alignment unless when we want a different alignment.

Re: To Mr. Rao, XBrowse totals (SOLVED)

Posted: Sun Nov 15, 2020 4:27 pm
by Armando
Mr. Rao:

Thank you very much.

Regards