Using data from two tables in page

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
dlee
Veteran Member
Posts: 137
Joined: 2020-04-14 00:21
Location: South Carolina, USA
Contact:

Using data from two tables in page

Post by dlee » 2023-05-24 03:30

I have 2 tables and I need to know if it is possible to include data from both tables in the same page? I understand it will take some coding to do this but I need to know how much of a challenge it will be, if it is even possible.
Thanks, TD

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

Re: Using data from two tables in page

Post by jsetzer » 2023-05-24 05:22

If this is just for display, simplest solution could be creating a custom page with two iframes, each loading a tableview in Embedded mode. This can be done in 5 minutes, I think.

But if you need to work with data of both tables this will become more complicated. For example if selecting records in one table shall filter records in the other table. I don't know about your usecase.
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

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

Re: Using data from two tables in page

Post by jsetzer » 2023-05-24 06:00

I'm sorry, my previous answer (which I cannot edit any more) was wrong.

I have just tested it. It is no problem to add two iframes and to load Detail Views in Embedded mode or any other page.

But the problem is:
TableView does not support Embedded=1 parameter. I forgot about this. This means when loading TableView into iframe, the navbar and menus will be visible. Removing them has to be done differently, for example by using Javascript.

Here is the simple version with two embedded table views (tables: tasks, projects) in two iframes as a starting point:

Code: Select all

<?php
include("lib.php");
include("header.php");
?>
<style>
    iframe {
        width: 100%;
        min-height: 40vh;
    }
</style>
<iframe src="tasks_view.php"></iframe>
<hr/>
<iframe src="projects_view.php"></iframe>
<?php
include("footer.php");
Code_7KzgaXNuX1.png
Code_7KzgaXNuX1.png (236.48 KiB) Viewed 4311 times

I am going to post another article in a few minutes showing how to get rid of the navbars inside the iframes automatically. Stay tuned.
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

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

Re: Using data from two tables in page

Post by jsetzer » 2023-05-24 06:15

OK, here is a solution for showing two table views in the same (custom) page without navbars.

(1) Create custom page

Code: Select all

<?php
// file: test_iframes.php
// custom page in project-root directory
include("lib.php");
include("header.php");
?>
<style>
    iframe {
        width: 100%;
        min-height: 40vh;
        display: none;
    }
</style>
<iframe src="tasks_view.php" onload="$j(this).fadeIn()"></iframe><br />
<iframe src="projects_view.php" onload="$j(this).fadeIn()"></iframe>
<?php include("footer.php");
(2) Remove navbar in iframed-pages

Code: Select all

<!-- file: hooks/footer-extras.php -->
<script>
    jQuery(function() {
        if (window.frames.length == 0 && window.parent.frames.length > 0) 
            jQuery(".users-area > nav.navbar").remove();
    });
</script>
Result

chrome_InAmNIEnEe.png
chrome_InAmNIEnEe.png (206.63 KiB) Viewed 4309 times

PS: I have to admit, it did take longer than the announced 5 minutes. Anyway, I hope this helps or at least gives a starting point.
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

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

Re: Using data from two tables in page

Post by jsetzer » 2023-05-24 06:29

If you, like me, dislike the gap at the top of the iframe's content which remains visible after removing the navbar, ...

chrome_LuYYkjDOpm.png
chrome_LuYYkjDOpm.png (14.97 KiB) Viewed 4309 times

... you can also remove the element ".top-margin-adjuster". Here is the modified code for hooks/footer-extras.php:

(2) Remove navbar and top-margin in iframed-pages

Code: Select all

<!-- file: hooks/footer-extras.php -->
<script>
    jQuery(function() {
        if (window.frames.length == 0 && window.parent.frames.length > 0) {
            jQuery(".users-area > nav.navbar").remove();
            jQuery(".top-margin-adjuster").remove();
        }
    });
</script>
Result
chrome_wgImkDv00k.png
chrome_wgImkDv00k.png (88.55 KiB) Viewed 4309 times
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

dlee
Veteran Member
Posts: 137
Joined: 2020-04-14 00:21
Location: South Carolina, USA
Contact:

Re: Using data from two tables in page

Post by dlee » 2023-05-24 21:58

Thank you Jan, will try these !
TD

Post Reply