xBrowse footer counting on cell / field-condition ?

xBrowse footer counting on cell / field-condition ?

Postby ukoenig » 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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby nageswaragunupudi » Wed Mar 07, 2018 1:24 pm

Code: Select all  Expand view  RUN

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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » Wed Mar 07, 2018 6:45 pm

Mr. Rao,

I included the lines but returns in all cases 0 :cry:
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


Image
Last edited by ukoenig on Thu Mar 08, 2018 9:55 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby nageswaragunupudi » Wed Mar 07, 2018 8:43 pm

This is a working sample:
Code: Select all  Expand view  RUN
 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() ;
      )

 


Image

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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » Wed Mar 07, 2018 9: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 :D

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 :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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse footer counting on cell / field-condition ?

Postby Marc Venken » Thu Mar 08, 2018 9: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » 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 :D
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 :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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby Marc Venken » Thu Mar 08, 2018 1: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » Thu Mar 08, 2018 2: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » 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

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse footer counting on cell / field-condition ?

Postby nageswaragunupudi » 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: Select all  Expand view  RUN

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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse footer counting on cell / field-condition ?

Postby ukoenig » 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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests