xbrowser footer

xbrowser footer

Postby wartiaga » Mon Dec 02, 2019 12:54 pm

Hello,

Why this:

Lista2:aCols[1]:cFooter := { || Ltrim( Str( Lista2:KeyNo() ) ) + " / " + LTrim( Str( Lista2:KeyCount() ) ) }
Lista2:Refresh()

Show me {||...} in footer?

Thanks in advance.
wartiaga
 
Posts: 210
Joined: Wed May 25, 2016 1:04 am

Re: xbrowser footer

Postby cnavarro » Mon Dec 02, 2019 1:01 pm

wartiaga wrote:Hello,

Why this:

Lista2:aCols[1]:cFooter := { || Ltrim( Str( Lista2:KeyNo() ) ) + " / " + LTrim( Str( Lista2:KeyCount() ) ) }
Lista2:Refresh()

Show me {||...} in footer?

Thanks in advance.


Use this
Code: Select all  Expand view

Lista2:aCols[1]:bFooter   := { || Ltrim( Str( Lista2:KeyNo() ) ) + " / " + LTrim( Str( Lista2:KeyCount() ) ) }
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: xbrowser footer

Postby wartiaga » Mon Dec 02, 2019 1:14 pm

cnavarro wrote:
wartiaga wrote:Hello,

Why this:

Lista2:aCols[1]:cFooter := { || Ltrim( Str( Lista2:KeyNo() ) ) + " / " + LTrim( Str( Lista2:KeyCount() ) ) }
Lista2:Refresh()

Show me {||...} in footer?

Thanks in advance.


Use this
Code: Select all  Expand view

Lista2:aCols[1]:bFooter   := { || Ltrim( Str( Lista2:KeyNo() ) ) + " / " + LTrim( Str( Lista2:KeyCount() ) ) }
 


Thank you, works great, but Lista2:KeyCount() is counting all records and i use a scope in lista2, how i can display the real count (not count deleted)? Thank you again.
wartiaga
 
Posts: 210
Joined: Wed May 25, 2016 1:04 am

Re: xbrowser footer

Postby cnavarro » Mon Dec 02, 2019 2:15 pm

Try with
Code: Select all  Expand view

oBrw:aCols[ 1 ]:nFooterType := AGGR_COUNT
oBrw:aCols[ 1 ]:bSumCondtion := { |v,o| ( oBrw:cAlias ) -> ( !Deleted() ) }
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: xbrowser footer

Postby nageswaragunupudi » Mon Dec 02, 2019 5:45 pm

oBrw:KeyCount() is the same as ( oBrw:cAlias )->( OrdKeyCount() )

OrdKeyCount() is a (x)Harbour function.

By default OrdKeyCount() respects Scopes and Filters but includes deleted records also. This is what we all should know.

If we want OrdKeyCount() not to include deleted records, we should set filter to "SET FILTER TO !DELETED()"

If we are particular that oBrw:nLen or oBrw:KeyCount() should not include deleted records then

Code: Select all  Expand view

USE MYTABLE ....
SET FILTER TO !DELETED()
GO TOP
// over and above this, we can use Scopes also.

// now build xbrowse
 


If we want to set some filter like "AGE > 40", then set filter like this:
Code: Select all  Expand view

SET FILTER TO AGE > 47 .AND. !DELETED()
 


OrdKeyNo() also is effected in the same way.

Note:
1. Using oBrw:nLen is faster than using oBrw:KeyCount().
2. These are issues relating to using the (x)Harbour function OrdKeyCount() but not XBrowse.
Regards

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

Re: xbrowser footer

Postby wartiaga » Tue Dec 03, 2019 2:22 am

cnavarro wrote:Try with
Code: Select all  Expand view

oBrw:aCols[ 1 ]:nFooterType := AGGR_COUNT
oBrw:aCols[ 1 ]:bSumCondtion := { |v,o| ( oBrw:cAlias ) -> ( !Deleted() ) }
 


Thank you!
wartiaga
 
Posts: 210
Joined: Wed May 25, 2016 1:04 am

Re: xbrowser footer

Postby wartiaga » Tue Dec 03, 2019 2:23 am

nageswaragunupudi wrote:oBrw:KeyCount() is the same as ( oBrw:cAlias )->( OrdKeyCount() )

OrdKeyCount() is a (x)Harbour function.

By default OrdKeyCount() respects Scopes and Filters but includes deleted records also. This is what we all should know.

If we want OrdKeyCount() not to include deleted records, we should set filter to "SET FILTER TO !DELETED()"

If we are particular that oBrw:nLen or oBrw:KeyCount() should not include deleted records then

Code: Select all  Expand view

USE MYTABLE ....
SET FILTER TO !DELETED()
GO TOP
// over and above this, we can use Scopes also.

// now build xbrowse
 


If we want to set some filter like "AGE > 40", then set filter like this:
Code: Select all  Expand view

SET FILTER TO AGE > 47 .AND. !DELETED()
 


OrdKeyNo() also is effected in the same way.

Note:
1. Using oBrw:nLen is faster than using oBrw:KeyCount().
2. These are issues relating to using the (x)Harbour function OrdKeyCount() but not XBrowse.


Thank you Mr. Nages, I use ! Deleted() in index condition to solve this issue.
wartiaga
 
Posts: 210
Joined: Wed May 25, 2016 1:04 am

Re: xbrowser footer

Postby nageswaragunupudi » Tue Dec 03, 2019 9:40 am

Thank you Mr. Nages, I use ! Deleted() in index condition to solve this issue.

Please do NOT use FOR conditions in Indexes.

The purpose of indexes is also to speed up queries (FILTERS). The RDD does not consider indexes with FOR conditions for optimization. That way we forgo some benefits of having indexes.

As I suggested please use FILTER TO !DELETED().

There is not much performance impact if the percentage of deleted records is less.

Create an additional index tag on every large dbf as
Code: Select all  Expand view

INDEX ON DELETED() TAG DELETED
 


Then the filter "SET FILTER TO !DELETED()" also is fully optimized.

Better we familiarize ourselves with the way RDD optimizes filters.
Regards

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

Re: xbrowser footer

Postby Enrico Maria Giordano » Wed Dec 04, 2019 1:03 pm

I can't see any optimization in the following sample:

Code: Select all  Expand view
#include "Fivewin.ch"


REQUEST DBFCDX


FUNCTION MAIN()

    LOCAL nSec

    LOCAL n, i

    RDDSETDEFAULT( "DBFCDX" )

    SET OPTIMIZE ON

    DBCREATE( "MYTEST", { { "TEST", "C", 100, 0 } } )

    USE MYTEST

    FOR i = 1 TO 300000
        APPEND BLANK

        REPLACE FIELD -> test WITH "TEST" + LTRIM( STR( i ) )

        IF i % 2 = 0
            DELETE
        ENDIF
    NEXT

    INDEX ON FIELD -> test TAG TEST TO MYTEST FOR !DELETED()

    nSec = SECONDS()

    n = 0

    WHILE !EOF()
        n++
        SKIP
    ENDDO

    ? n, SECONDS() - nSec

    CLOSE

    FERASE( "MYTEST.CDX" )

    USE MYTEST

    INDEX ON DELETED() TAG DELETED TO MYTEST
    INDEX ON FIELD -> test TAG TEST TO MYTEST

    SET FILTER TO !DELETED()

    nSec = SECONDS()

    n = 0

    WHILE !EOF()
        n++
        SKIP
    ENDDO

    ? n, SECONDS() - nSec

    CLOSE

    FERASE( "MYTEST.DBF" )
    FERASE( "MYTEST.CDX" )

    RETURN NIL


Results: 0.07 and 1.06.

Can you change my sample to show the optimization, please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: xbrowser footer

Postby Enrico Maria Giordano » Sat Dec 07, 2019 5:44 pm

Rao, have you had the time to test my sample?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests