(also posted in the C11 newsgroup)
Hi,
I’m trying to filter a browse. I have a couple of filter fields and a
dropdown that are supposed to filter the browse. The first filter field
has to be filled in.
After a change in the any of the three filters I call a derived
windowmanager procedure:
ThisWindow.reset_filter PROCEDURE()
CODE
if filter1 <> ''
filter_exp = 'sql(lower(ADDRESS) like <39>%' & FILTER1 & '%<39> and
(<39>' & FILTER2 & '<39> is null or lower(ADDRESS) like <39>%' & FILTER2 &
'%<39>) and (<39>' & LOC:COMMUNITY & '<39> is null or <39>' &
loc:community & '<39> = city ))'
else
filter_exp = 'V_C:address = <39>ZZZ<39>'
end
The seecond filter should result in nothing showing on the browse, and is
the filter set on entering the procedure (cos Filter1 is blank when you
start), and we don’t want to waste time displaying everything in the file
on startup.
I have !filter_exp as the filter for browse and filter_exp as a reset
field for the browse. I’ve added a couple of other things in desperation:
BRW1.ApplyRange after changing filter1, and explicitly calling
BRW1.ResetSort after the parent method in TakeAccepted. I’ve put some
PROP:Logs in the trace to see what is going on, and it looks like this:
SETview(VIEW:65FC1F0:USE_CAPS."V_CASE_BASIC_ADDRESS":065FC108H)
Filter reset to sql(lower(ADDRESS) like '%2%' and ('' is null or
lower(ADDRESS) like '%%') and ('Rigolet' is null or 'Rigolet' = city ))
02D64H(2) 14:20:52.247 Parsing T9 Cursor 106658244 : SELECT A."FILE_NO",
A."FIRST_NAME", A."LAST_NAME", A.ADDRESS, A.CITY, A."POSTAL_CODE",
A."SERV_PROVIDER", A."HOUSING_START" FROM USE_CAPS."V_CASE_BASIC_ADDRESS"
A WHERE ( A.ADDRESS = 'ZZZ' ) ORDER BY A.CITY, A."FILE_NO" Return
Code: 0 Time Taken:0.00 secs
036DCH(2) 14:36:07.624 SETview(VIEW:
6DA2288:USE_CAPS."V_CASE_BASIC_ADDRESS":06DA21A0H) Time Taken:0.00 secs
036DCH(2) 14:36:07.624 CLEAR(USE_CAPS."V_CASE_BASIC_ADDRESS":0122CD68H)
Time Taken:0.00 secs
036DCH(2) 14:36:13.739 Filter before resetsort is sql(lower(ADDRESS) like
'%2%' and ('' is null or lower(ADDRESS) like '%%') and ('Rigolet' is null
or 'Rigolet' = city ))
036DCH(2) 14:36:13.739 Parsing T9 Cursor 114661708 : SELECT A."FILE_NO",
A."FIRST_NAME", A."LAST_NAME", A.ADDRESS, A.CITY, A."POSTAL_CODE",
A."SERV_PROVIDER", A."HOUSING_START" FROM USE_CAPS."V_CASE_BASIC_ADDRESS"
A WHERE ( A.ADDRESS = 'ZZZ' ) ORDER BY A.CITY, A."FILE_NO" Return
Code: 0 Time Taken:0.00 secs
036DCH(2) 14:36:13.941 After resetsort
So what seems to be happening is that yes, the filter variable is being
changed, confirmed a) after the embed on filter1 sets it, and b) before
the second call to ResetSort in ThisWindow.TakeAccepted, but in both cases
the query sent to the backend is based on the original value of filter_exp
and not the current value.
What do I need to do to get it to use the current value of the filter
variable?
Jon