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: Date widget  (Read 9686 times)
Candy M.
Posts: 139


« on: July 02, 2009, 08:03:50 pm »

We would like to have a general CONSTRUCT statement, but...since
that is not possible, we have simulated one in an input array
where the array is all strings.

Is there a way to have access to that calendar widget with a button?
The date could be determined then we could set in our string field (EDIT) field.

Thanks,
Candy
Reuben B.
Four Js
Posts: 1119


« Reply #1 on: July 07, 2009, 08:18:03 am »

We would like to have a general CONSTRUCT statement, but...since
that is not possible, we have simulated one in an input array
where the array is all strings.

...
Thanks,
Candy

I think it is possible to write a general CONSTRUCT statement. 

Does each column of the array correspond to each field.  If so have a look at my auitree example in sourcefourjs and in particular the generic zoom functionality.  The technique is to have 3 columns for each generic field, one text, one numeric, and one date and hide the two columns that don't apply.  (I didn't do it in that example but change the pre-processor line in the .per so that the date columns are DATEEDITS, I was more focused on the sorting of the columns in the display array rather than inputing data).  I know that code seems like a lot of work and I wish it was easier but its cheaper than coding practically the same thing over and over again.

If you have gone the other way and made each row of the array correspond to each generic field (and have two columns prompt and value) then its not so easy in an array.  Maybe something like this would have potential, using the DOM functions to hide the ununsed columns and rows

Code
  1. LAYOUT
  2. GRID
  3. {
  4. Field 1 [f01        :f02       :f03         ]  
  5. Field 2 [f11        :f12       :f13         ]
  6. }
  7. END
  8. ATTRIBUTES
  9. f01 = formonly.field1c;
  10. DATEEDIT f02 = formonly.field1d, HIDDEN;
  11. f03 = formonly.field1n TYPE FLOAT, HIDDEN;
  12.  
  13. f11 = formonly.field2c, HIDDEN;
  14. DATEEDIT f12 = formonly.field2d;
  15. f13 = formonly.field2n TYPE FLOAT, HIDDEN;

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Sebastien F.
Four Js
Posts: 545


« Reply #2 on: July 07, 2009, 10:44:24 am »

Hi,

To make CONSTRUCT work properly, you need to have the field types defined in the 42f form file in the sqlType attribute. This attribute is used by CONSTRUCT to handle criteria input validation and to generate the SQL conditions.

I did not test but I would try to build the 42f file dynamically, using a template with place holders such as:
    sqlType="%FIELD_TYPE_001%"
and replace the type attributes according to your needs...

Unfortunately CONSTRUCT is not generic enough to take a dynamic list of fields, so you need to prepare a CONSTRUCT with all the fields and hide/disable the fields that are not used. Thus, the form must define as many fields as your biggest table has, unused fields will be hidden / disabled at runtime.

Since column names are not known at compile time, and need to be static because the CONSTRUCT BY NAME or FROM field-list is static, you need to use generic column names (column001, column002, ...) and replace these generic names by the real database column names after CONSTRUCT has generated the SQL condition...

Just an idea, to be tested...

Seb
Sebastien F.
Four Js
Posts: 545


« Reply #3 on: July 07, 2009, 03:24:27 pm »

It should also be possible to adapt the form field views (widgets) by patching the 42f at runtime, to get a DATEEDIT where you expect.

And it would also be a good idea to base all of this on the schema files (.sch, .val), to build the forms according to the database column types... This is actually what fglform does when referencing tables and table columns to define form fields. You may argue that you can query the database system tables but then you need to adapt this to all type of databases. You will however have to decode the type info from .sch files, see fgldbslib.4gl in FGLDIR/src and Informix books about syscolumns for details.

Remember you can define field widget types and attributes with the .val file, see:

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/DatabaseSchema.html#VAL_FILE

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/FormSpecFiles.html#FF_ITEMTYPE_FIELD

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/FormSpecFiles.html#SECTION_SCHEMA

Seb
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines