FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse footer counting on cell / field-condition ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 12:02 PM

Hello,

I want to show 2 totals on Footer

  1. counting records where nValue > 0
  2. counting records where not empty string

NO value counter only counting valid records on condition 1 and 2 !

regards
Uwe :?:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 01:24 PM
Code (fw): Select all Collapse
oBrw:aCols[ 1 ]:nFooterType := AGGR_COUNT
oBrw:aCols[ 1 ]:bSumCondtion := { |v,o| o:Value > 0 }

oBrw:aCols[ 2 ]:nFooterType := AGGR_COUNT
oBrw:aCols[ 2 ]:bSumCondition := { |v,o| !Empty( o:Value ) }
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 06:45 PM
Mr. Rao,

I included the lines but returns in all cases 0 :-)
maybe there is still something else to be checked :-)

Deleted ( numeric 0 or 1 )

:aCols[3]:nFooterType := AGGR_COUNT
:aCols[3]:bSumCondition := { |v,o| o:Value > 0 }


Likes ( numeric 0 - 4 )

:aCols[6]:nFooterType := AGGR_COUNT
:aCols[6]:bSumCondition := { |v,o| o:Value > 0 }


Filter 1 ( text )

:aCols[7]:nFooterType := AGGR_COUNT
:aCols[7]:bSumCondition := { |v,o| !EMPTY( o:Value ) }
:aCols[7]:nFootStrAlign := AL_RIGHT


Filter 2 ( text )

:aCols[8]:nFooterType := AGGR_COUNT
:aCols[8]:bSumCondition := { |v,o| !EMPTY( o:Value ) }
:aCols[8]:nFootStrAlign := AL_RIGHT


Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 08:43 PM
This is a working sample:
Code (fw): Select all Collapse
  USE CUSTOMER NEW SHARED
   SET FILTER TO RECNO() < 11
   GO TOP

   XBROWSER "CUSTOMER" COLUMNS "STATE", "AGE", "MARRIED", "SALARY" SETUP ( ;
      oBrw:lFooter            := .t., ;
      oBrw:Age:nFooterType    := AGGR_COUNT, ;
      oBrw:Age:bSumCondition  := { |v,o| o:Value % 2 == 1 }, ;
      oBrw:State:nFooterType  := AGGR_COUNT, ;
      oBrw:State:bSumCondition := { |v,o| "A" $ o:Value }, ;
      oBrw:Salary:nFooterType := AGGR_SUM, ;
      oBrw:Salary:bSumCondition := { || .NOT. FIELD->MARRIED }, ;
      oBrw:bRClicked := { |r,c,f,o| o:Age:VarPut( o:Age:Value + 1 ) }, ;
      oBrw:MakeTotals() ;
      )




Footer of "State" shows the number of cases where the name contains "A".
Footer of "Age" shows the number of cases where age is ODD.
Footer of "Salary" shows the total of Salary drawn where MARRIED is FALSE.

Please recheck your program
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 09:34 PM
Mr. Rao,

I moved to the end

:MakeTotals()
:CreateFromCode()
END

before it was defined somewhere in the middle
now the values are visible :-)

But there is still another problem :
I noticed after changing the column-values on right mouseclick (at runtime), the totals are not updated.

//"TOPICNO", "FORUM", "T_DELETE", "DATE", "AUTHOR", "LIKE", "INFO1", "INFO2"

oBrw:bRClicked := { || ( nRPos := RECNO(), ;
nCPos := oBrw:SelectedCol():nCreationOrder, ;
IIF( nCPos = 3, SET_DEL(), NIL ), ;
IIF( nCPos = 6, SET_LIKE(oBrw), NIL ), ;
oBrw:RefreshCurrent() ) }

Like-level on button-action

@ 585, 170 BTNBMP oBtn[5] OF oDlg ;
SIZE 70, 25 PIXEL 2007 ; // B / H
PROMPT "0 %" ;
ACTION ( DBSELECTAREA(cFileName), ;
NET_RLOCK( 3, 3 ), ;
(cFileName)->LIKE := 0, ;
NET_ULOCK(), oBrw:RefreshCurrent() );
FILENAME c_path1 + "Like1.bmp" ;
LEFT


I found :

DATA aSumSave // Array with previous val/totals for recalc totals

Thank You very much
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 10:32 PM

I modified my sample above. Please see the revised sample. I added a right-click action which keeps the value of Age increasing by one. You can see that the totals also get changed.

Now the question is why this is not working for you.

You are making changes to DBF directly and xbrowse does not know that you changed the data. Always the best way is the modify data though xbrowse. When you are using xbrowse, you need not write reclocks, recunlocks, etc. XBrowse takes care of everything automatically.

Just use oBrw:oCol:VarPut( <newvalue> )
If the <newvalue> is different from the existing value, xbrowse writes the value to the dbf, takes care of all locking issues and also makes necessary modifications to the totals. If indexed column is modified, xbrowse refreshes the data and otherwise, it refreshes the row only.

Instead of doing yourself, just tell xbrowse what to do and it does it properly and completely.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 09:07 AM

This is very usefull.

In my Xbrowse I have lot's of row that are deleted, but I don't want them to be removed. (I need to see them somethimes) I have SET DELETED ON on top of Prog.

Can you show the code to display deleted count ?

To toggle between showing the deleted or not deleted records, I have to set a Filter for !deleted() and refresh Xbrowse ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:04 AM
Marc,

Yes that is the reason I wanted to add the footer-infos.
I'm just working on the needed changes using Rao's sample.
works great :-)
It shows if there are still any marked as deleted records
I'm using a extra field ( indexed ) that shows the deleted-status using a image.
If You don't need this solution :
just select any column-footer where do You want to show the deleted-counter

counter shown on column 3 footer

:aCols[3]:nFooterType := AGGR_COUNT
:aCols[3]:bSumCondition := { |v,o| (cFileName)->(DELETED()) } // You defined Alias


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 01:53 PM

Uwe,

Will this kind of extra's slow down the browse performance on huge databases (200.000 recs)?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 02:10 PM

Marc,

tested with 200000 records and counted without problems.

regards
Uwe :D

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:01 PM
I noticed a problem counting < deleted > after a < PACK >
The deleted value is still visible ( must be reset to 0 )
a value of 2 is used for deleted to show the image

I added
oBrw:aCols[3]:bFooter := { || 0 } after < PACK >
the footer shows 0 now but doesn't count anymore



any solution for a reset :-)

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:13 PM
I noticed a problem counting < deleted > after a PACK
The deleted value is still visible ( must be reset to 0 )

Because XBrowse does not know that you Packed.
If you take actions like this inform XBrowse to recalculate totals afresh.

Code (fw): Select all Collapse
PACK
oBrw:MakeTotals()




I added
oBrw:aCols[3]:bFooter := { || 0 } after < PACK >
the footer shows 0 now but doesn't count anymore

If you directly assigned any values to cFooter or bFooter, only that value is displayed. Because you assigned bFooter := { ||0 } always 0 will be displayed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:33 PM

Mr. Rao,

thank You very much
it is working now. I didn't think about < oBrw:MakeTotals() >
because it was defined on xBrowse-init.
It means it must be called in case of any new-calculation like < PACK >.

I will prepare a new download-link to show the changes.

regards
Uwe :D

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion