Title: Display An Array with Variable Number of Column Post by: Sean H. on April 11, 2023, 12:48:15 pm I was wondering if it is possible to get pointed in the right direction of handling a data structure like this with a Form Table.
Code
The dates data column can have an unknown number of dates depending on the duration, like for example Code
Ideally it would be great to show it in a Form Table like the below Code
Title: Re: Display An Array with Variable Number of Column Post by: Reuben B. on April 13, 2023, 02:15:22 am Before I offer solutions, I'll just direct readers to https://4js.com/ask-reuben/ig-28/ and the beginning of this presentation https://4js.com/files/documents/wwdc21/plenary/A6_Table_vNext.pdf which help illustrate the architecture of Form Tables and give insight as to why you can do certain things and why you can't do certain things.
For the need described, I would ask the following questions - what is the expected number of rows in the array what is the expected number of entries in the dynamic array of date with the proposed DATE 01, DATE02 columns, is there any expected functionality associated with those columns. For instance if you clicked on DATE 03 column header, would you expect a sort on DATE 03 etc is it possible for the number of date columns to increate during the display of the form Based on those responses, then you might consider 1. Turn the array of dates into a string that contains a list of dates Code
Code
2. Display a count of the dates in a BUTTONEDIT field, and make the list of dates available in a popup Code
Code
3. A solution you might have considered already is to hardcode the maximum number date columns, and hide the date columns that aren't used e.g. hard coded maximum 20 dates. Code
4. If the number of rows or dates is not excessive, you could consider using a WebComponent to display the data as you'd like https://github.com/FourjsGenero/wc_2darray. I make the disclaimer for number of rows not being excessive because if you are getting into the hundreds and thousands then you start needing to think of ways to not send every row to the front-end 5. Dynamic dialogs is also an option and will give you a UI that is closest to what you want. You will need to parse the data beforehand to determine the maximum number of columns and hence determine your fields array http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassDialog_dd_field_definition.html which would be something like ... Code
In creating your form dynamically http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_dynamic_dialogs_forms.html then you would be creating a form with max_date_count date columns In setting the array values http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_dynamic_dialogs_fields.html, you'd have two loops Code
The downside with this approach is that you need to consider what happens if a date is added during the lifetime of the dialog, if this exceeds the maximum then you need to exit and reinstantiate the dialog. If the list is static then not an issue. Personally I'd favour approach 1 or 2 or a combination thereof e.g. BUTTONEDIT that displays a STRING that if 1-n dates lists them, if more than n dates displays a string "X dates from MIN to MAX" and the user clicks the BUTTONEDIT to see them Code
Hope this helps, Reuben |