Page 1 of 1

Using data from two tables in page

Posted: 2023-05-24 03:30
by dlee
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

Re: Using data from two tables in page

Posted: 2023-05-24 05:22
by jsetzer
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.

Re: Using data from two tables in page

Posted: 2023-05-24 06:00
by jsetzer
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 4352 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.

Re: Using data from two tables in page

Posted: 2023-05-24 06:15
by jsetzer
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 4350 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.

Re: Using data from two tables in page

Posted: 2023-05-24 06:29
by jsetzer
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 4350 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 4350 times

Re: Using data from two tables in page

Posted: 2023-05-24 21:58
by dlee
Thank you Jan, will try these !
TD