Page 1 of 1

Get children table from other table

Posted: 2021-03-24 12:38
by mfilipe
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 4484 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 4484 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 4484 times
Any suggestion?

Re: Get children table from other table

Posted: 2021-03-30 10:50
by mfilipe
Anyone can help?

Re: Get children table from other table

Posted: 2021-03-30 12:49
by jsetzer
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.

Re: Get children table from other table

Posted: 2021-04-12 10:43
by mfilipe
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.

Re: Get children table from other table

Posted: 2021-04-27 11:09
by mfilipe
Anyone can help?

Re: Get children table from other table

Posted: 2021-04-27 11:10
by mfilipe
Anyone can help?

Re: Get children table from other table

Posted: 2021-04-27 11:28
by jsetzer
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.

Re: Get children table from other table

Posted: 2021-06-25 10:01
by mfilipe
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()?