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: Using addDisplayArrayTo()  (Read 11751 times)
Lu?s T.
Posts: 39


« on: September 26, 2019, 05:47:56 pm »

I want to transform a static display array in a dynamic one.

The manual says it is possible using the method addDisplayArrayTo of the ui.Dialog.Class.

Code
  1. ui.Dialog.addDisplayArrayTo(
  2.   fields DYNAMIC ARRAY OF RECORD
  3.                        name STRING,
  4.                        type STRING
  5.                    END RECORD,
  6.   screenRecord STRING )

What I don't understand is where should I refer to the program array!

The static code I want to replace is:

Code
  1. DEFINE myArray DYNAMIC ARRAY of
  2.    RECORD
  3.        code        INTEGER
  4.        description STRING
  5.    END RECORD
  6.  
  7. DISPLAY ARRAY myArray to myScreenArray.*

Anyone has experience with this?

Thanks

Sebastien F.
Four Js
Posts: 545


« Reply #1 on: September 30, 2019, 07:47:30 am »

Hello !

First of all please can you tell us why you want to use dynamic dialogs?

Is there a good reason to not use static dialogs?

Then, to answer your question:

The purpose of dynamic dialogs is to handle data models dynamically, so it makes no sense to associate a program array with a static structure to a dynamic dialog!

For more details see:

https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_dynamic_dialogs_fields.html

Seb
Lu?s T.
Posts: 39


« Reply #2 on: September 30, 2019, 01:24:49 pm »

I have several forms with screen arrays (tables), The interaction I want with all of them are similar. That's why I prefer to generic code. In other hand I prefer to design the form manually because each has is owns additional elements.

As far I understand I write directly in screen array with setFieldValue() method. So it is my problem of mapping an eventual program array to the screen array or getting directly the info from the database, using base.SqlHandle.

As I am using "ON FILL BUFFER" I am stuck because I don't know how to get the dimension of the array.  fgl_dialog_getBufferLength() returns 0 and d.getArrayLength() seems to return the number of elements of the array and not the maximum elements.

Should I inspect the XML of the form (TableElement.buffersize), or there are a method for this?
Sebastien F.
Four Js
Posts: 545


« Reply #3 on: September 30, 2019, 08:11:25 pm »

Luis,

ON FILL BUFFER trigger should work see

https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassDialog_addTrigger.html

Please prepare a sample that reproduces your issue and send it to the support.

We will then contact you to help.

Seb
Reuben B.
Four Js
Posts: 1119


« Reply #4 on: October 07, 2019, 12:07:09 am »

Luis,


One puzzling thing you said

Code
  1. As I am using "ON FILL BUFFER" ... and d.getArrayLength() seems to return the number of elements of the array and not the maximum elements.
with ON FILL BUFFER, the screen array only has the visual rows in memory.  That is if the database cursor returns 1000 rows but on the screen only 10 rows are visible, only 10 rows will ever be in the array at a time.  So note in this example https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_prog_dialogs_dafill_paged.html the line FETCH ABSOLUTE row c1 INTO arr.*, i.e i is a value between 1 and say 10, not between 1 and 1000

Also my example fgl_zoom https://github.com/FourjsGenero/fgl_zoom is an example of a generic use of dynamic dialog with a display array (and a construct), probably similar to what you are trying to achieve although it doesn't use ON FILL BUFFER.    In particular around lines 776 of https://github.com/FourjsGenero/fgl_zoom/blob/master/fgl_zoom.4gl.  I actually keep a copy of the entire array in memory, hence the use of this.data[row, column] instead of using base.SqlHandle.getResultValue directly.

Reuben






Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Lu?s T.
Posts: 39


« Reply #5 on: October 09, 2019, 03:55:16 pm »

Hi Sebastien and Reuben,

I did some experiments and made it work.

The problem was that I didn't know how to make the equivalent of (count=-1) in the Dynamic Dialog version. Without that fgl_dialog_getbufferlength() and fgl_dialog_getBufferStart() don't work as expected. I had to call d.setArrayLength() after creating the Display Array Dialog
Code
  1.    CALL d.addDisplayArrayTo( thFielList, theSreenRecord )
  2.    CALL d.setArrayLength( theSreenRecord, -1 )
  3.  

Infomix SQL allows me to select only certain rows using SKIP and FIRST:

Code
  1.    SELECT SKIP ofs FIRST len field1, ..., fieldn FROM ...
  2.  

I prepare the select and only get the rows based on what is returned by fgl_dialog_getbufferlength() and fgl_dialog_getBufferStart().

Works very well.

Thanks

Luis


Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines