FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to create this xbrowse-filter ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
How to create this xbrowse-filter ?
Posted: Fri May 22, 2015 03:43 PM
Hello,

I have a question about creating a xBrowse-filter

There are 2 browser
1. Customer
2. a list of accomplishments of a month for each customer ( browser 1 ) shown in browser 2
the same index is used for browser 1 and 2

Upper ( surname + forename )

because surname can be the same and forename is different
what is the best solution, to filter browser 2 ?

2. for better reading, is it possible to hide 0 - values ?
maybe better to convert values to strings and using a array for browser 2 ?

the screenshot shows just the basics and there is still a lot to do.



best 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: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to create this xbrowse-filter ?
Posted: Fri May 22, 2015 03:54 PM
Uwe

Don't know if this will help you but I use a 'trick' with an Ado (sql ) filter by extracting the value of a Get by keystroke using the :GetText() method and setting the filter to that alltrim string .. it basically immitates an incremental search and refreshed xBrowse with the filter results as I type in each keystroke.

If you are using .dbf you might try Set Order to instead of the :Filter Ado method.

Rick Lipkin

Code (fw): Select all Collapse
//-------------
Static Func  _Isearch( oSearch1, cSearch1, oId1, cId1, oLbx, oRsCust, cLname, oLname  )

cSearch1 := Alltrim( oSearch1:GetText() )
cLName   := substr(cSearch1+space(50),1,50)
oLname:ReFresh()
cId1     := alltrim( oId1:GetText() )

If Empty( cSearch1 ) .and. Empty( cId1 )

   cLname := space(50)
   oLname:ReFresh()

   oRsCust:Filter := ""
   oRsCust:Filter := "[Last Name] = 'bogus'"
   oLbx:ReFresh()
   Return(.T.)
Endif


Do Case
Case (Empty( cSearch1 ) .and. Empty( cId1 ))
     oRsCust:Filter := "[Last Name] = 'bogus'"

Case !empty( cSearch1 ) .and. Empty( cId1 )
     oRsCust:Filter := "[Last Name] like '"+cSearch1+"%'"

Case (!empty( cSearch1 ) .and. !Empty( cId1 ))
     oRsCust:Filter := "[Last Name] like '"+cSearch1+"%' and [Customer Id] like '"+cId1+"%'"

Case empty( cSearch1 ) .and. !Empty( cId1 )
     oRsCust:Filter := "[Customer Id] like '"+cId1+"%'"

OtherWise
     oRsCust:Filter := "[Last Name] = 'bogus'"
End Case

oLbx:ReFresh()

Return(.t.)

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to create this xbrowse-filter ?
Posted: Fri May 22, 2015 04:17 PM
Rick,

thank You very much.
I will test it, if it works for me.

Hiding the 0 - values, to clean the browser 2 is easy

1. day of 31

oCol:bStrData := { || IIF( (cMonat)->T1 = 0, " ", (cMonat)->T1 ) }

a working filter selecting a customer in browser 1

Filter called on change in browser 1

WITH OBJECT oBrw1
:lIncrFilter := .t.
:lSeekWild := .t.
:bChange := { || FILTER1(cMonat, oFld) }
END


FUNCTION FILTER1(cMonat, oFld)

// fiels from DBF 1
cNName := ("KUNDE")->NAME1
cVName := ("KUNDE")->NAME

// change to dBF 2
DBSELECTAREA( cMonat )
(cMonat)->( DBSETFILTER( NIL ) )
SET FILTER TO (cMonat)->KUNDE = cNName .and. (cMonat)->NAME1 = cVName
DBGOTOP()

// move to browser 2
oBrw2:SetFocus()
oBrw2:Refresh()

// reading fields from browser 2, to refresh folderpage 1
V_GET(nPage, cMonat)
oFld:aDialogs[ nPage ]:Update()

RETURN NIL




best 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: How to create this xbrowse-filter ?
Posted: Sat May 23, 2015 02:54 AM

1) To show blanks instead of Zeros

Recommended way is to set
oBrw:lDisplayZeros := .t.
( To the extent possible, we may not directly use bStrData)

2) Master Child Browses:

I assume you are using DBFCDX.

The preferred way is to SET SCOPED RELATION.

I understand you created an index tag on Upper( KUNDE + NAME1 ) on ( cMonat ) DBF.
Let us assume
(1) field lengths of NAME1 and NAME OF KUNDE are the same as KUNDE and NAME1 of ( cMonat )

If so proceed like this:

( cMontat )->( OrdSetFocus( <tagnameof the above index expression> )
SELECT KUNDE
SET RELATION TO UPPER( NAME1 + NAME ) INTO ( cMontat ) SCOPED
[or]
KUNDE->( OrdSetRelation( cMontat, { || UPPER(NAME1+NAME) }, "UPPER(NAME1+NAME)" ) )
KUNDE->( DBGOTOP() )

Now create all browses.
In the first browse:
oBrw1:bChange := { || oBrw2:Refresh(), V_GET(nPage,cMontat), oFld:aDialogs[nPage]:Update() }

Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to create this xbrowse-filter ?
Posted: Sat May 23, 2015 11:13 AM
Mr. Rao,

thank You very much for the infos.
Using RELATIONS instead of a filter is working fine.
I tested using oBrw2:lDisplayZeros := .T. // hide 0
but couldn't see any result
oCol:bStrData := { || IIF( (cMonat)->T1 = 0, " ", (cMonat)->T1 ) }
is working fine

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: How to create this xbrowse-filter ?
Posted: Sat May 23, 2015 11:30 AM

Sorry
oBrw:lDisplayZeros := .f. // not .t.

and pls remove bStrdata

Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to create this xbrowse-filter ?
Posted: Sat May 23, 2015 06:16 PM
Everything is working fine now.
The 1. folderpage is finished with all needed date-calculations.
Thank You for the help



best 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.

Continue the discussion