NetTalk Central

Author Topic: Memform - embed code on Button ?  (Read 5435 times)

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Memform - embed code on Button ?
« on: December 07, 2017, 01:08:26 PM »
Hi All,
NT 10
I have a memory form with 10 fields with check boxes for each field.  Depending on which fields are checked, I want to use them to build a filter which will be used for the child browse.
I put a button as the last field in the list but can't get it to run the code ( apparently code runs on CHANGE record when window is accepted).
Question, How can I tell server that user has finished selecting filters, build the filter string and refresh the child browse ( which will now use the filter).
TIA,
Ron Jolda

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Memform - embed code on Button ?
« Reply #1 on: December 08, 2017, 03:04:37 AM »
Hi,

When the child browse is on the same memory form, just make sure the server side code part for the button is used.
When the button is clicked, execute the server side code for the button. That's where you build the filter string and store it in a session queue value, e.g. 'childfilter'.

In the serverside part of the button, add the the child browse to be refreshed, and use the session queue value in the template filter part  of the child browse.

To make sure that the values of the 10 fields be used when creating the filter string, move all the separate field values to corresponding session queue values. A good place to do that is in the CompleteForm-routine or the ValidateAll-routine (Bruce told me lately).

Cheers,
Rene



Rene Simons
NT14.14

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: Memform - embed code on Button ?
« Reply #2 on: December 08, 2017, 11:41:48 AM »
Interesting,  I could NOT get the code to run for a BUTTON ( field set up as a BUTTON).  However, I changed the field to a Checkbox and got it to execute the code.
Ron

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Memform - embed code on Button ?
« Reply #3 on: December 08, 2017, 02:11:00 PM »
Is your form a popup?
I have had my share of difficulties with popups.
Rene Simons
NT14.14

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: Memform - embed code on Button ?
« Reply #4 on: December 09, 2017, 06:08:53 AM »
Yes, it is popup - interesting thought.  Have you tried to revert it from being a pop up and what have your results been?
Ron

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: Memform - embed code on Button ?
« Reply #5 on: December 09, 2017, 08:53:59 AM »
SOLUTION!!!!
I have a Memory Form with a bunch of attributes of Psych Meds and uses.   E.g.  Anxiety, depression, PTSD, OCD, organic psychosis.   These are check boxes.
I have a CHILD Browse of the Psych Meds and it gets filtered by the attributes selected.
ANSWER,
I made each if the check boxes refresh the Child Browse.
In the Child Browse, Embed 2, Before Browse Loop -   11 Set Filter:

CODE:
===========================================

 ThisView{prop:Filter} =  ''  ! have to clear it and rebuild with each pass.

if p_web.GetSessionValue('bhm:Depression') = 1
   
    if ThisView{prop:Filter} =  ''  ! cstring
        ThisView{prop:Filter} =  'bhm:Depression= <39>X<39>'
     
    ELSE   
        ThisView{prop:Filter} = ThisView{prop:Filter} & ' AND ' & 'bhm:Depression=<39>X<39>'
    END 
     
END

if p_web.GetSessionValue('bhm:BiPolar') =1
     
    if ThisView{prop:Filter} =  ''  ! cstring
        ThisView{prop:Filter} = 'bhm:BiPolar=<39>X<39>'
    ELSE   
        ThisView{prop:Filter} = ThisView{prop:Filter} &  ' AND ' & 'bhm:BiPolar=<39>X<39>'
    END
       
END


if p_web.GetSessionValue('bhm:Panic') = 1
   
    if ThisView{prop:Filter} =  '' ! cstring
       ThisView{prop:Filter} = ThisView{prop:Filter} & 'bhm:Panic=<39>X<39>'   
    ELSE   
       ThisView{prop:Filter} = ThisView{prop:Filter} & ' AND ' &  'bhm:Panic=<39>X<39>'   
    END
         
END
=============================

This builds the filter real time and resets the Child Browse with check or uncheck of any attribute ( have 19 of them).
Kinda neat!

FWIW,
Ron Jolda

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Memform - embed code on Button ?
« Reply #6 on: December 10, 2017, 12:28:12 PM »
Hi,

Yeah. This is the direction I wanted you to go.
Excelt for the fact that you reset the browse whenever a checkbox is set.
When your dataset is big and there is a lot of data to filter. It can be a pain to have to wait every time you click a checkbox.
I would prefer to just run the code when the "Go"or "Whatever" button is clicked. After the required checkboxes are set.
But congrats on the result.

Rene
Rene Simons
NT14.14