Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Construct Question  (Read 7045 times)
Gary C.
Posts: 109


« on: May 01, 2017, 12:51:10 pm »

Hello

I have a need to initialise the form values when using a construct statement, in essence "remembering" the users previous search criteria when entering the dialog.

Is this possible? I know I can read the field values but I am struggling to see how to set them.

Thanks
Daniel N.
Posts: 6


« Reply #1 on: May 02, 2017, 11:13:35 am »

Hello

in our applications we automatically save the construct values in a table and offer the user a button to restore the last saved values.

In AFTER CONSTRUCT we use the AUI Tree to find all elements that were part of the CONSTRUCT with SelectByPath("//*[@dialogType=\"Construct\"]")
and search their Attributes "name" and "value" with getAttribute("name")  and getAttribute("value"). 

If the user press the Button for "RestoreValues" we also use the AUI-Tree with the same SelectByPath and set the Attribute "value" with
setAttribute("value") with the saved contents for all contruct fields.
Daniel N.
Posts: 6


« Reply #2 on: May 02, 2017, 12:23:43 pm »

Hello again

I don't know if you are familiy with AUI Tree. Attached please find the modified demo program Field.4gl and Field1.per to show
how you can get and restore the construct values.
Hope it helps.

* Field.4gl (3.97 KB - downloaded 620 times.)
* Field1.per (2.31 KB - downloaded 608 times.)
Reuben B.
Four Js
Posts: 1046


« Reply #3 on: May 02, 2017, 01:56:00 pm »

I like Andreas generic code.

The methods ui.Dialog.setFieldValue http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDialog_setFieldValue.html and ui.Dialog.getFieldValue http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDialog_getFieldValue.html introduced in 3.00 could be used instead of the AUI tree reading and writing and would be safer in the long run.

If you don't want to go down the generic code path then DISPLAY will do what you were after ...

Code
  1.        CONSTRUCT BY NAME where_clause ON field1, field2, field3
  2.        BEFORE CONSTRUCT
  3.            DISPLAY ">0" TO field1
  4.            CALL DIALOG.setFieldValue("field2", "A*")
  5.  
  6.        AFTER CONSTRUCT
  7.            IF int_flag THEN
  8.                EXIT CONSTRUCT
  9.            END IF
  10.            DISPLAY "Field 1 = ", GET_FLDBUF(field1)
  11.            DISPLAY "Field 2 = ", DIALOG.getFieldValue("field2")
  12.    END CONSTRUCT
  13.    DISPLAY where_clause

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Gary C.
Posts: 109


« Reply #4 on: May 03, 2017, 09:02:07 am »

Hi

Thanks for your help Andrea/Reuben - I've got that working now.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines