Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Temporarily Filter a CursorAdapter
Message
From
12/01/2018 01:15:27
 
 
To
10/01/2018 06:11:20
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01657053
Message ID:
01657141
Views:
97
>>I don't normally use CursorAdapters but I'm maintaining some code that uses them (actually, instances of the CursorAdapter class). Consider me a CA newbie :)
>>
>>I have 2 Tables, Referrals and Proponents. One Referral may have one or more Proponents.
>>
>>Over a period of years, Proponents may become obsolete, so they get marked as "Historical". When this happens, historical Proponents should no longer appear in picklists which allow users to add new Proponent(s) to a Referral. However, the Referral itself should always show all selected Proponents, whether any have subsequently been marked as historical or not.
>>
>>So far there is 1 CA defined, which shows all Proponents for a given Referral (historical or not). However, at this time the Add New Proponent(s) function uses that same CA, so it's showing all Proponents rather than just those which are not marked Historical.
>>
>>What I'd like to do is continue to use the same CA but temporarily apply a filter where historical = .F., then remove the filter once the pick form is closed.
>
>2 typical strategies for such a problem: you load/filter/select before each show of the pick list or you create a stable cursor dependant on changes to first cursor. Second case can become hairy if # of dependencies grows, but often offers better "try it" performance as a wait in situations triggering dependancy check is often "natural".
>
>For strategy 2: Used simple array property to store references of CAs to trigger dependant refresh on if only dependant on one cursor and biz classes calculating list of CA to refresh/update in complex cases.
>
>The sledge hammer of strategy 1 is often fast enough - KISS is a solid reason.
>
>>
>>Seems to me this could be a common request so it might be built-in to the CA class but I can't find anything that looks promising.
>>Is there anything built-in? If not, can anyone offer strategies that would achieve this?
>>
>>I was thinking maybe just INDEX the cursor FOR historical = .F. but that seems kludgy.
>
>Only kludgy if index is not BINARY

Thanks, everyone, for the ideas for approaches.

It turns out there was already some spaghetti code issuing built-on-the-fly SET FILTER commands. I ended up creating a temporary cursor filtered on historical = .F. and using that to power the selection grid. Had to chase down about a dozen references to the old alias but search&replace was very helpful.

Kinda feels like yanking the tablecloth out from under a fully set table for 12, then replacing it with another one ;) Par for the course in maintenance programming.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform