Page 1 of 1

Creating Auto Fields in a Table

Posted: 2021-06-17 09:40
by gatenet
Hello all, here is my situation.
I want to make a table with services that will have some fields (id, service name etc) then I want to make another table that will pull dynamic the records from the first table and turn them into fields. For example in the table services a user will put 2 records let's say Webhosting and Domain Names, so the second table will have these 2 records for fields (Webhosting and Domain Names) after some time the user will create a new record let's say Support, then I want the second table to have a third field called Support.
Is there any way to make this?

Re: Creating Auto Fields in a Table

Posted: 2021-06-17 19:05
by pbottcher
Hi,

not sure I got exactly what you mean, but if the second table is kind of a single record with all the records from the first table (for one field), then you could have one field to hold an index for the user and a second field that would hold all entries from the first table.

Re: Creating Auto Fields in a Table

Posted: 2021-06-18 05:16
by jsetzer
So you'd like to turn records of one table into columns of a second table like so:

Table "Services"

Code: Select all

-id
-name
Data
1 ; Webhosting
2 ; Domain Names
3 ; Support

Table "TABLE2"

Code: Select all

-id
-webhosting
-domain_names
-support
That's not possible "on the fly" with standard AppGini, because AppGini requires a static model for generating database tables, serverside- and clientside code and user interface. When working with AppGini, AppGini itself does not know about any records inside any existing database on any remote or local server at all.

You may consider using a SQL command in _after_insert hook of "services" table for creating new columns in TABLE2.
You may consider renaming existing columns in TABLE2 in before_update/after_update hook of "services" table using SQL.
You may consider deleting existing columns in TABLE2 in before_delete hook of "services" table using SQL.

But creating/modifying/deleting columns this will not change any User Interface.

Adding dynamic forms for data entry and listing of data, data-validation and serverside storage after POST will be separate tasks.

That's quite a lot of work.

Re: Creating Auto Fields in a Table

Posted: 2021-06-24 19:31
by gatenet
Thank you my friend I will look at it