Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional filtering of a Browse List (C6.1 - ABC)

Status
Not open for further replies.

TinLegs

Programmer
Jan 14, 2003
100
NZ
In addition to the normal sort tabs I would like to allow a user to be able to further Filter the Browse List conditionally.

Filter example: YEAR(CUS:RecordDate)=YEAR(TODAY())

... to enable optional viewing of current records only.

ie. A variable say named 'BrowseFilter' that has two radio options named ( ) All Records and ( ) Current Only displayed on the browse for conditional filtering by the user.

I note commands such as SetFilter, AddSortOrder but I do not understand how to implement them or if they can be at which embeded point(s).

There does not appear to be anything in the Clarion example apps so I was wondering if this is possible?

Clarification on this would be greatly appreciated.

 
Hi!

There are two forms of BRWx.SetFilter() i.e. SetFilter(FilterString) & SetFilter(FilterString, ID). It is always better to use the second one i.e. with ID as you can issue filter statements separately without the need to concatenate them. Please that that the ID is processed in REVERSE order i.e. from '9' to '1'. Using SetFilter without and ID uses a default ID of 5.

For your example, you can do the following on the EVENT:NewSelection or EVENT:Accepted of the Option control ::

Code:
IF BrowseFilter = 'C'  ! Current Only
   BRWn.SetFilter('YEAR(CUS:RecordDate)= ' & YEAR(TODAY(), '9Z')
ELSE
   BRWn.SetFilter('', '9Z')
END
BRWn.ResetSort(True)

Similarly you can do for other conditions ::

Code:
IF <second condition>
   BRWn.SetFilter(<second filter string>, '9Y')
ELSE
   BRWn.SetFilter('', '9Y')
END
BRWn.ResetSort(True)

Regards
 
Hi!

small typo - It should be YEAR(TODAY()[red])[/red].

Regards
 
Thank you very much ShankarJ - Got it working in just minutes thanks to your code but had a another issue when selecting a new tab (BrowseFilter lost) but seems I have got around that problem now by putting your code into a Routine which is called when a new tab is selected.

I do try and learn from the help files, examples and experimentation as I am sure others do but its not always easy to find a solution (no hair left to pull out) so its great to get help from experienced programmers such as yourself. Thank you for supporting the Clarion community. TinLegs, New Zealand.
 
Hi!

Filter are specific to the Sort Order and if the Tab change signals a change in Sort Order, you need to reapply the filters. One way to avoid that is to set the filters in the ApplyFilter method before Parent call. Using a Routine which is called in WM.Init and on EVENT:NewSelection of the SHEET control does the job also.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top