Using addDisplayArrayTo()

Started by Luís T., September 26, 2019, 05:47:56 PM

Previous topic - Next topic

Luís T.

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 (genero) Select

ui.Dialog.addDisplayArrayTo(
   fields DYNAMIC ARRAY OF RECORD
                        name STRING,
                        type STRING
                    END RECORD,
   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 (genero) Select

DEFINE myArray DYNAMIC ARRAY of
    RECORD
        code        INTEGER
        description STRING
    END RECORD

DISPLAY ARRAY myArray to myScreenArray.*


Anyone has experience with this?

Thanks


Sebastien F.

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.

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.

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.

Luis,


One puzzling thing you said

Code (genero) Select
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.

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 (genero) Select

    CALL d.addDisplayArrayTo( thFielList, theSreenRecord )
    CALL d.setArrayLength( theSreenRecord, -1 )


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

Code (sql) Select

    SELECT SKIP ofs FIRST len field1, ..., fieldn FROM ...


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