Page 1 of 1
xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 12:02 pm
by ukoenig
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
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 1:24 pm
by nageswaragunupudi
Code: Select all | Expand
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 ) }
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 6:45 pm
by ukoenig
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_RIGHTFilter 2 ( text )
:aCols[8]:nFooterType := AGGR_COUNT
:aCols[8]:bSumCondition := { |v,o| !EMPTY( o:Value ) }
:aCols[8]:nFootStrAlign := AL_RIGHT
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 8:43 pm
by nageswaragunupudi
This is a working sample:
Code: Select all | Expand
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
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 9:34 pm
by ukoenig
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" ;
LEFTI found :
DATA aSumSave // Array with previous val/totals for recalc totalsThank You very much
Uwe
Re: xBrowse footer counting on cell / field-condition ?
Posted: Wed Mar 07, 2018 10:32 pm
by nageswaragunupudi
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.
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 9:07 am
by Marc Venken
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 ?
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:04 am
by ukoenig
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 Aliasregards
Uwe
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 1:53 pm
by Marc Venken
Uwe,
Will this kind of extra's slow down the browse performance on huge databases (200.000 recs)?
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 2:10 pm
by ukoenig
Marc,
tested with 200000 records and counted without problems.
regards
Uwe
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:01 pm
by ukoenig
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
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:13 pm
by nageswaragunupudi
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.
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.
Re: xBrowse footer counting on cell / field-condition ?
Posted: Thu Mar 08, 2018 10:33 pm
by ukoenig
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