NetTalk Central

Author Topic: Conditional filter in Browse  (Read 3559 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Conditional filter in Browse
« on: December 26, 2014, 06:53:19 PM »
Hi

I wanted to have two menu items which executed the same browse but when Item1 was chosen the filter was different than when Item2 was chosen.

Now in this browse I already have a filter and to avoid it getting too complicated to code in the template (!) I have put the code into the ValidateRecord embed point (If <conditions> then cycle.)  So I just wanted to set a session variable when Item1 was pushed and clear it when Item2 was pushed so that I could code something like this:

If p_web.gsv('external',1)  !got here from Item1
   if <set of conditions> then cycle.
END

I looked in vain for a place to set the variable in the PageHeaderTag - p_web.ssv('external',1) when Item 1 was chosen and to clear it after Item 2 was chosen ( p_web.ssv('external',0) but both pieces of code were always executed so I am obviously looking in the wrong place.

Where could I put this SSV to unambiguously set and clear the variable?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Conditional filter in Browse
« Reply #1 on: December 28, 2014, 09:21:57 PM »
Hi Keith,

You are making the mistake of hand-coding something that the templates already do for you. This is bad for 2 reasons;

a) It is much better to set the Filter for the VIEW - which in turn pushes the filtering onto the back-end and

b) Writing hand-code will always be "less forward compatible" than using template features. - Which is not to say this hand-code is a problem, but I know the code the templates generate, and so I can make sure that is backward compatible in future releases, whereas I don't know the hand-code you are generating so sometimes that has to change.

Here are some tips thought for what you want to do;

a) Add a parameter to the menu items. Say something like;
'menufilter=x1'
and
'menufilter=x2'

b) In the browse do a StoreValue so the parameters are "remembered". You can do this at the first embed in the procedure.

p_web.StoreValue('menufilter')

c) Use the "Conditional Filters" template options - using the SesisonValue of Menufilter as the condition;

p_web.GSV('MenuFilter') = 'x1'

Cheers
Bruce