Page 1 of 1
How can I show the children record button like appgini does in the detail view?
Posted: 2022-02-11 20:22
by nycwebmaster
How can I show the children record button like appgini does in the detail view?
I have latest versions of appgini and appginihelper.
How can I show a button in the table view that will take you to the children's records?
Re: How can I show the children record button like appgini does in the detail view?
Posted: 2022-02-11 21:01
by jsetzer
Maybe I do not understand your question:
The detail view's children-link is a feature of the detail view. It shows a filtered list of child record which are related to exactly one detail record.
For example a course has students.
In table view there are many records, each may have various children records. So, which of them shall be listed when clicking the additional button(s)?
Can you please explain your use case a bit more. You can add buttons or links to the first column of every row. And you can set javascript function or links per button per row.
Re: How can I show the children record button like appgini does in the detail view?
Posted: 2022-02-11 21:40
by jsetzer
Use the
.addLink()
function of AppGini Helper Javascript Library with href like...
Code: Select all
CHILDTABLENAME_view.php?filterer_FKCOLUMNNAME=%ID%
This should open the TV of CHILDTABLENAME and list all records filtered by foreign key.
(see example in next post)
Re: How can I show the children record button like appgini does in the detail view?
Posted: 2022-02-12 09:00
by jsetzer
Here is an example.
Model
Table
partners
has children records of table
contacts
.
contacts.partner_id
is lookup referencing
partners
table.
- chrome_v82WgKUuqW.png (4.22 KiB) Viewed 1462 times
Code
The following code produces that inline-toolbar per row. The last button (better so say "link") opens a filtered page of contacts filtered by contacts.partner_id of the specific partner-recor (per row).
Code: Select all
$j(document).ready(function () {
AppGiniHelper.TV
.addOpenButton()
.addLink("partners_mindmap.php?SelectedID=%ID%", "record")
.addLink("partners_tree.php?SelectedID=%ID%", "align-left")
.addLink("contacts_view.php?filterer_partner_id=%ID%", "user", "...") // see this line!
.setWidth(0, 180);
});
First parameter of
.addLink()
function is the
HREF
. Note that the placeholder
%ID%
will be replaced by the primary key of each individual row.
Output
This is the result:
- chrome_Utt1A3GSgR.png (18.56 KiB) Viewed 1462 times
Screenrecording
- ezgif.com-gif-maker (6).gif (254.15 KiB) Viewed 1462 times
Re: How can I show the children record button like appgini does in the detail view?
Posted: 2022-02-12 09:22
by jsetzer
If you just want to add buttons to the top toolbar of Table View (TV), check out the following code:
Code
Code: Select all
// file: hooks/TABLENAME-tv.js
$j(document).ready(function () {
AppGiniHelper.TV.getTopButtons()
.addLink("index.php", "cog", "Custom Button #1", Variation.info, "Do you really want to hurt me?")
.addButton(function () { alert("Clack!") }, "flash", "Custom #2 - Click", Variation.Primary, "Do you really want to make me cry?")
.addLink("admin/pageHome.php", "cog", "Admin Area", Variation.danger);
});
Parameters:
- AddLink
- HREF
- icon name
- (optional) Caption
- (optional) Variation
- (optional) Prompt (for confirmation dialog)
- AddButton
- Javascript function call
- icon name
- (optional) Caption
- (optional) Variation
- (optional) Prompt (for confirmation dialog)
Output
- chrome_EQ2GjIhouf.png (29.7 KiB) Viewed 1461 times
Screenrecording
- ezgif.com-gif-maker (7).gif (95.79 KiB) Viewed 1461 times