Get children table from other table

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Get children table from other table

Post by mfilipe » 2021-03-24 12:38

Hi,

I'm trying to make someting in my new DB and i'm not getting it.
The thing is.

I have a budget table, that have a budget_items table as children

Capturar1.PNG
Capturar1.PNG (96.9 KiB) Viewed 2780 times



and I want that in the order table when I select in drop-down list that budget,

Capturar2.PNG
Capturar2.PNG (105 KiB) Viewed 2780 times

the budget_items of that budget appears as children table of the orders table.

Capturar2 - Cópia.PNG
Capturar2 - Cópia.PNG (133.04 KiB) Viewed 2780 times
Any suggestion?

mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Re: Get children table from other table

Post by mfilipe » 2021-03-30 10:50

Anyone can help?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Get children table from other table

Post by jsetzer » 2021-03-30 12:49

I don't know if I have understood you question completely.

If you want to filter the rows of the child-tab table (or even display a modified list) after changing a value of the master-record in user interface (UI), I'm afraid there is nothing built in. This is not the way master-children have been implemented in AppGini and other RAD/CRUD software.

Maybe you should explain your target, so we can better understand your needs and perhaps propose a different, but working solution.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Re: Get children table from other table

Post by mfilipe » 2021-04-12 10:43

My idea is,

I have a table of budgets, that have a children table budget_items.

Then I have the orders table that I have a lookup field where I choose what is budget sent to the customer who will generate this order. When I choose this budget my intention is that show as children table of this order the children table of the budget selected.

I hope I have clarified better.

mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Re: Get children table from other table

Post by mfilipe » 2021-04-27 11:09

Anyone can help?

mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Re: Get children table from other table

Post by mfilipe » 2021-04-27 11:10

Anyone can help?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Get children table from other table

Post by jsetzer » 2021-04-27 11:28

Honestly speaking, I did not get your idea.

And definitely AppGini does not support changing the list of related child-records when changing a lookup selection in one master record in UI.

If you need filtering of all child records on the fly, I have no efficient hooks-only idea. If you can cope with totals or some kind of summary of items of the selected budget, consider adding a calculated field at budget level and then use autofill option. This will show the summary field immediately after selection of a budget.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mfilipe
Posts: 12
Joined: 2020-01-18 17:18

Re: Get children table from other table

Post by mfilipe » 2021-06-25 10:01

I'm near of my need.

I add a second id_lock in my budget_items. So the first id_lock define child-records to the budget and the second id_lock define child-records to the order.

After that add this code to orders_after_update and after_insert.

sql("UPDATE `budget_items` SET `id_lock2` = {$data['id']} WHERE `budget_items`.`id_lock` = {$data['budget']}", $eo);

Work fine, but if I have the same budget items for many orders I have to update the Page to update the value of id_lock2

It was any way to use this code on orders.init()?

Post Reply