How to Display Recent Child Records in Modal Add New separate display DV
-
- Posts: 21
- Joined: 2024-05-12 10:13
How to Display Recent Child Records in Modal Add New separate display DV
I'm working on a document tracking system, and I need some help with customizing the "Add New" modal for child tables. Specifically, I would like to display the three most recently encoded records from the child table within the modal. This would allow users to see the latest entries as they add new records, helping them decide what actions to take without needing to close the modal to check the preview tracking information.
I’ve already tried using the Detail view settings to NOT check the separate display, but this approach restricts the number of records I can view per page in my "Routing" table and also may provide furthermore customizations.
I’ve already tried using the Detail view settings to NOT check the separate display, but this approach restricts the number of records I can view per page in my "Routing" table and also may provide furthermore customizations.
- Attachments
-
- Screenshot 2024-10-22 125427.png (129.11 KiB) Viewed 528 times
Re: How to Display Recent Child Records in Modal Add New separate display DV
First idea which came into my mind as a starting point:
Inject an iframe:
In
This will show an embedded Table View without any header/menu/footer and list the filtered records. This will already consider user permissions.
Inject an iframe:
src
= TABLENAME_view.php?Embedded=1¶meter_for_filtering=123
In
TABLENAME_init()
hook check for parameter and use $options
for filtering.This will show an embedded Table View without any header/menu/footer and list the filtered records. This will already consider user permissions.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
- D Oliveira
- AppGini Super Hero
- Posts: 353
- Joined: 2018-03-04 09:30
- Location: David
Re: How to Display Recent Child Records in Modal Add New separate display DV
jsetzer wrote: ↑2024-10-22 07:32First idea which came into my mind as a starting point:
Inject an iframe:
src
=TABLENAME_view.php?Embedded=1¶meter_for_filtering=123
InTABLENAME_init()
hook check for parameter and use$options
for filtering.
This will show an embedded Table View without any header/menu/footer and list the filtered records. This will already consider user permissions.
Brilliant!
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
sorry I can't seem to follow, could I get furthermore guidance? and again huge thanks for helping
1st problem. with <iframe src="RoutingActionInformation_view.php?Embedded=1&filter_field=value" style="width: 100%; height: 600px; border: none;"></iframe>
I tried this to embed the HTML above the modal however this also adds in the Table View of the RoutingActionInformation, so I end up 2 RoutingActionInformation Table View
2nd problem. with function RoutingActionInformation_init(&$options, $memberInfo, &$args) { //logic etc.
its here Im also struggling to make the filter/logic work to only show the child-table-routingactioninformation that is equals to its parent table-documents controlnumber. I would like it to only show the 3 recent encoded of routingactioninformation of the document
1st problem. with <iframe src="RoutingActionInformation_view.php?Embedded=1&filter_field=value" style="width: 100%; height: 600px; border: none;"></iframe>
I tried this to embed the HTML above the modal however this also adds in the Table View of the RoutingActionInformation, so I end up 2 RoutingActionInformation Table View
2nd problem. with function RoutingActionInformation_init(&$options, $memberInfo, &$args) { //logic etc.
its here Im also struggling to make the filter/logic work to only show the child-table-routingactioninformation that is equals to its parent table-documents controlnumber. I would like it to only show the 3 recent encoded of routingactioninformation of the document
Re: How to Display Recent Child Records in Modal Add New separate display DV
First things first: You should start with the filtering logic.2nd problem. [...] make the filter/logic work
According to docs, there are different ways for filtering TV data. This is how I do it which gives me maximum flexibility and control:
It is just a working example. Replace
tasks
by your table name and replace SQL conditions accordingly. You may also change parameter name custom_filter
to something different.Code: Select all
function tasks_init(&$options, $memberInfo, &$args)
{
// TEST filtering
$my_filter = Request::val("custom_filter");
switch ($my_filter) {
case 'closed':
$options->QueryWhere = "WHERE task_states1.is_finished";
break;
case 'open':
$options->QueryWhere = "WHERE NOT task_states1.is_finished";
break;
}
}
custom_filter=open
or custom_filter=closed
as URL. This should return the filtered records, only.https://YOURSERVER/YOURAPP/tasks_view.php?custom_filter=closed
As soon as it works with a simple filter, extend your logic. For example add more filters like
&custom_filter_parent_id=999
or whatever your need and, extend $options->QueryWhere
SQL conditions accordingly.Caution
There may be cases where
$options->QueryWhere
already contains SQL conditions. In these cases, do not concat "WHERE ..."
but concat "AND ..."
, otherwise you will get SQL errors.As soon as your filtering works as expected, we can start working on embedding a table view into another detail view.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
SLR I just got back from the weekends, and atm couldn't still make it work (not that good at programming) or am I not getting something right
/Hooks/RountingActionInformation.php
<iframe src="http://localhost/v4update/RoutingAction ... er=matched" style="width: 100%; height: 600px;"> </iframe>
<?php
function RoutingActionInformation_init(&$options, $memberInfo, &$args) {
// TEST filtering
$my_filter = Request::val("custom_filter");
switch ($my_filter) {
case 'matched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber";
break;
case 'unmatched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents.ControlNumber";
break;
}
}
I couldn't figure out on why my iframe src is not filtered, is in an almost infinity loop of view and it's showing the entire (with header and footer) view of the address. The help is always significantly grateful
/Hooks/RountingActionInformation.php
<iframe src="http://localhost/v4update/RoutingAction ... er=matched" style="width: 100%; height: 600px;"> </iframe>
<?php
function RoutingActionInformation_init(&$options, $memberInfo, &$args) {
// TEST filtering
$my_filter = Request::val("custom_filter");
switch ($my_filter) {
case 'matched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber";
break;
case 'unmatched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents.ControlNumber";
break;
}
}
I couldn't figure out on why my iframe src is not filtered, is in an almost infinity loop of view and it's showing the entire (with header and footer) view of the address. The help is always significantly grateful
Re: How to Display Recent Child Records in Modal Add New separate display DV
As mentioned before, I highly recommend testing your filtering-logic in browser, first, before you start with embeding an...?custom_filter=matched
<iframe/>
.- Check this URL in your browser:
http://localhost/v4update/RoutingActionInformation_view.php?custom_filter=matched
Does it work at all? - If not, add some debugging, for example:
Reload your browser and check if there isCode: Select all
function RoutingActionInformation_init(&$options, $memberInfo, &$args) { // TEST filtering $my_filter = Request::val("custom_filter"); var_dump($my_filter); switch ($my_filter) { case 'matched': $options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber"; break; case 'unmatched': $options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents.ControlNumber"; break; } var_dump($options->QueryWhere); exit(); }
matched
andWHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber
in output. - If so, remove the debugging-lines (
var_dump(...)
,exit()
), reload page, then, in Admin Area, check for failed SQL queries. We don't know your table names nor do we know your column-names. Perhaps there is a typo or different column-naming. - If there are failed SQL queries, double check your column names and your
$options->QueryWhere
statement, then, in Admin Area clear error-queries, in Users Area reload your table view page, go back to Admin Area and check if there are new error-queries. - As soon as your table view filter works, go on with embedding
<iframe/>
.
Tip: add&Embedded=1
to your URL. As already mentioned, this will remove header from your embedded table view.
We are trying to help you. But please read carefully when we give advice to you.not that good at programming
When posting here, please take the time to put your code fragments in
<code>...</code>
for better readability.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
1. kinda? its shows string(7) "matched"
2. I added the debugging, and yes it shows in output string(7) "matched" string(70) "WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber"
3.I checked the admin/query logs for any failed SQL queries but did not find any. For context, my database consists of two tables: 'Documents' and 'RoutingActionInformation'. The 'Documents' table has a primary key field called 'ControlNumber', which is also used as a foreign key in the 'RoutingActionInformation' table.
Thank you so much for your consistent support and guidance, truly appreciate it.
2. I added the debugging, and yes it shows in output string(7) "matched" string(70) "WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber"
3.I checked the admin/query logs for any failed SQL queries but did not find any. For context, my database consists of two tables: 'Documents' and 'RoutingActionInformation'. The 'Documents' table has a primary key field called 'ControlNumber', which is also used as a foreign key in the 'RoutingActionInformation' table.
Thank you so much for your consistent support and guidance, truly appreciate it.
- Attachments
-
- Screenshot 2024-11-05 163115.jpg (23.55 KiB) Viewed 246 times
-
- Screenshot 2024-11-05 162921.jpg (45.82 KiB) Viewed 246 times
-
- Screenshot 2024-11-05 161829.jpg (22.96 KiB) Viewed 246 times
Re: How to Display Recent Child Records in Modal Add New separate display DV
Thanks for naming the tables.
Just guessing:
Can you please retry with
When you
Hope this is the reason.
Just guessing:
Can you please retry with
Documents1.ControlNumber
instead of Documents.ControlNumber
Code: Select all
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents1.ControlNumber";
When you
var_dump($options->QueryFrom);
you should see inner joins FROM RoutingActionInformation
on Documents
table, having an alias 'Documents1'
. So, your SQL query conditions should refer to Documents1
, not to Documents
.Hope this is the reason.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
The issues seem to be the same for having it as Documents1: string(7) "matched" string(71) "WHERE RoutingActionInformation.ControlNumber = Documents1.ControlNumber"
<iframe src="http://localhost/v4update/RoutingAction ... er=matched" style="width: 100%; height: 600px;"> </iframe>
<?php
function RoutingActionInformation_init(&$options, $memberInfo, &$args) {
// TEST filtering
$my_filter = Request::val("custom_filter");
var_dump($my_filter);
switch ($my_filter) {
case 'matched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents1.ControlNumber";
break;
case 'unmatched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents1.ControlNumber";
break;
}
var_dump($options->QueryWhere);
exit();
}
<iframe src="http://localhost/v4update/RoutingAction ... er=matched" style="width: 100%; height: 600px;"> </iframe>
<?php
function RoutingActionInformation_init(&$options, $memberInfo, &$args) {
// TEST filtering
$my_filter = Request::val("custom_filter");
var_dump($my_filter);
switch ($my_filter) {
case 'matched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents1.ControlNumber";
break;
case 'unmatched':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents1.ControlNumber";
break;
}
var_dump($options->QueryWhere);
exit();
}
- Attachments
-
- Screenshot 2024-11-05 174701.jpg (51.48 KiB) Viewed 242 times
Re: How to Display Recent Child Records in Modal Add New separate display DV
Do not write any
As you can see, this messes up everything and this will not work. Hook files have a defined set of PHP-functions, identified by naming conventions. You cannot just put any HTML there!
Once again:
Please test the filtering logic in pure plain table view, first.
And please, when posting here, always put code fragments inside
<iframe/>
-HTML-code in hooks file directly!As you can see, this messes up everything and this will not work. Hook files have a defined set of PHP-functions, identified by naming conventions. You cannot just put any HTML there!
Once again:
Please test the filtering logic in pure plain table view, first.
And please, when posting here, always put code fragments inside
[code]...[/code]
blocks for better readability.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
Oh, I see. Understood! If I'm not supposed to add my <iframe /> in the hooks, where should I add it?
Additionally, the filter I am trying to use compares the ControlNumber of both Documents and RoutingActionInformation. If they match, I want to display the RoutingActionInformation entries. Is there something wrong with my query?
Noted: I'll used the
Code: Select all
<iframe src="http://localhost/v4update/RoutingActionInformation_view.php?&Embedded=1&custom_filter=matched" style="width: 100%; height: 600px;"> </iframe>
Code: Select all
WHERE RoutingActionInformation.ControlNumber = Documents.ControlNumber
Code: Select all
fragments.
Re: How to Display Recent Child Records in Modal Add New separate display DV
Filtering Table View Data
Still, it is important that opening a browser-tab with this URL
If filtering logic in plain table view still does not work I recommend more debugging like so:
Anyway, there are different ways for embedding HTML. You can prepend quoted HTML-code to
Still, it is important that opening a browser-tab with this URL
http://localhost/v4update/RoutingActionInformation_view.php?custom_filter=matched
returns the filtered table you expect.If filtering logic in plain table view still does not work I recommend more debugging like so:
- In
TABLENAME_init()
hook function,var_dump($options->QueryFrom);
andvar_dump($options->QueryWhere);
- Check both outputs to see obvious errors like different table names or misspelled aliases
- If, after resolving obvious SQL errors, table view still does not work as expected, let AppGini build your final SQL query and check the results in your favourite SQL tool (for example Adminer or PhpMyAdmin):
Change table names andwhere
-clause accordingly:
This is the dumped SQL statement in my scenario:Code: Select all
function TABLENAME_init(&$options, $memberInfo, &$args) { // your filtering logic here // change QueryWhere depending on custom filter parameters // Replace QueryWhere according to YOUR specific condition(s) $options->QueryWhere = "WHERE `TABLENAME`.`id` IN (1, 2, 3, 5, 8, 13, 21, 34, 55)"; // enable debugging: true|false $debug = true; if ($debug) { $sql = $options->buildQuery($options->QueryFieldsTV); echo "<p>Clipboard-copy and test the following SQL command in your SQL tool:</p>"; echo "<code>{$sql}</code>"; exit; } // ... }
- Open your SQL tool, paste the dumped SQL command, run the query and check the results. As long as your SQL tool cannot run your query, AppGini generated code cannot run your query neither. Your SQL tool may give more detailed information about the error.
- If you cannot find the mistake by yourself, post outputs from
var_dump($options->QueryFrom);
,var_dump($options->QueryWhere);
and especially$sql
here, maybe we can see it. - As mentioned before, there are situations in which
QueryWhere
already contains content due to permissions. Then do not concat "WHERE ...
" but "AND ...
"
First things first, but you will not stop asking, right?[...] <iframe /> [...], where should I add it?
Anyway, there are different ways for embedding HTML. You can prepend quoted HTML-code to
$html
variable in TABLERNAME_dv()
hook function. Caution: check $selectedID
variable, which may be empty in insert-mode and may be necessary for your filtering logic.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
I just realized—is there a way to iframe only the children of the Document component? What I need is to display only the RoutingactionInformation, which is a child of Document. Could someone elaborate on this approach for the forum?
Re: How to Display Recent Child Records in Modal Add New separate display DV
Question: does it work now? Any feedback welcome.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 21
- Joined: 2024-05-12 10:13
Re: How to Display Recent Child Records in Modal Add New separate display DV
sadly no,
Note back to the hooks/RoutingActioninformation.php, I still havent figured out and yes me entering the iframe in the table_templateDV.html looks just right but without the filter
and resulting I tried using this alternative as it already serves the filter that I want
isnt possible as it prompting No direct access allowed. is there a way to negate this?
Note back to the hooks/RoutingActioninformation.php, I still havent figured out and yes me entering the iframe in the table_templateDV.html looks just right but without the filter
Code: Select all
<?php
function RoutingActionInformation_init(&$options, $memberInfo, &$args)
{
// TEST filtering
$my_filter = Request::val("custom_filter");
switch ($my_filter) {
case 'match':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber = Documents.RoutingActionInformation";
break;
case 'unmatch':
$options->QueryWhere = "WHERE RoutingActionInformation.ControlNumber != Documents.RoutingActionInformation";
break;
}
}
Code: Select all
<iframe src="http://localhost/v4update/children-RoutingActionInformation?&Embedded=1" style="width: 100%; height: 200px;"> </iframe>
Code: Select all
I tried removing the if(!isset($Translation)) die('No direct access allowed.');
Re: How to Display Recent Child Records in Modal Add New separate display DV
Sorry, my question was not precise enough: I wanted to ask if your table view filters are working now.Question: does it work now? Any feedback welcome.
---
I have never seen such filename and I do not know that kind of file which you are using as
src
in your <iframe/>
: children-RoutingActionInformation?&Embedded=1
It is not a PHP-script. Did you forget the
.php
file extension? Your src
-attribute does not match any default AppGini naming convention for table views nor detail views, and I do not know if you have configured any custom .htaccess
redirection for handing such sources.Here are a few standard script-names for AppGini:
-
TABLENAME_view.php
Opens a table view forTABLENAME
-
TABLENAME_view.php?SelectedID=1
Opens a detail view forTABLENAME
, showing record, identified by primary key (AKA id)=1
, if exists. -
TABLENAME_view.php?SelectedID=1&Embedded=1
Same as above but in Embedded-mode without navbar
<iframe/>
. Due to security reasons <iframe/>
restrictions are quite complex. You could read and try to understand AppGini generated source code for <ifame/>
and learn from how BigProf handles it.---
For me it looks like I am not able to give any helpful information to you for a little progress on your filters-request.
Anyway, as soon as you have your filters running, it is not complicated, just two lines of PHP code in
/hooks/TABLENAME.php
produce such result:Nothing fancy:
Code: Select all
if (!$selectedID)
$html .= '<iframe src="TABLENAME_view.php?Embedded=1" width="100%" height="300"></iframe>';
<iframe/>
to the top.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<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 readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools