APPGINI HELPER

Topics related to AppGini plugins/add-ons go here.
Post Reply
User avatar
cesteban
Veteran Member
Posts: 52
Joined: 2018-04-18 09:56

APPGINI HELPER

Post by cesteban » 2022-12-01 17:51

Hi,

When I add a button to table view and click on the (Open) label, the SelectID parameter creates a URL with the name of the record's primary key and not the value I'm requesting:

Example;

.../northwind/customers_view.php?SelectedID=%CustomerID%

Of course I get the following Error:

Bad request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

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

Re: APPGINI HELPER

Post by jsetzer » 2022-12-01 19:23

Don't know for sure if I got your point. Do you mean Button or Link?

If .addButton, you are in control of the javascript function being executed on click.

If .addLink, the placeholder is %ID%, NOT %CustomerID%
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
cesteban
Veteran Member
Posts: 52
Joined: 2018-04-18 09:56

Re: APPGINI HELPER

Post by cesteban » 2022-12-02 00:13

Thanks,

This is the code at customers-tv.js file:

jQuery(function () {
let tv = AppGiniHelper.TV;
let customers = tv.getTableName();
let href = customers + "_view.php?SelectedID=%CustomerID%";
tv.addLink(href, "search", "Open");
});

Pressing the button opens a URL that is this:

http://sebusca.com.mx/northwind/custome ... CustomerID%

I think that the %Customer ID% tag is not being replaced by the customer ID that I am selecting, that is my question

Regards

Esteban

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

Re: APPGINI HELPER

Post by jsetzer » 2022-12-02 01:29

As said above, the placeholder is %ID%, NOT %CustomerID%.
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: 1806
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: APPGINI HELPER

Post by jsetzer » 2022-12-02 02:35

By the way, for just opening the row in Detail View, there is a shorthand function:

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(document).ready(function() {
    AppGiniHelper.tv.addButtonOpen();
});
.addButtonOpen() renders a button in every row. Check the URL at the bottom of the page in the following screenshot:

VoFb52iyVu.png
VoFb52iyVu.png (16.1 KiB) Viewed 1570 times

If you prefer a different icon or even text, you can pass those parameters:

Code: Select all

AppGiniHelper.tv.addButtonOpen("triangle-right", "Öffnen")
chrome_Vy1381tZnk.png
chrome_Vy1381tZnk.png (6.38 KiB) Viewed 1570 times
I'm using this a lot. Actually, I am placing such code in a javascript function in hooks/header-extras.php. Having such functions in a central place means it will render such buttons in every DV. I dont' have to place it in every single TABLENAME-dv.js.

Additional Links

Additionally, I'm often adding extra buttons for directly opening child-records of a record. This requires master-child relations, built based on lookups, obviously. In the following case there is a master-table partners, having id as primary key and mulitple child-tables (contacts, calculations, machines), having a lookup column named partner_id, each:

Code: Select all

$j(document).ready(function() {
    var tv = AppGiniHelper.TV;
    tv
        .addButtonOpen()
        .addLink("contacts_view.php?filterer_partner_id=%ID%", "user", "...")
        .addLink("calculations_view.php?filterer_partner_id=%ID%", "align-left", "...")
        .addLink("machines_view.php?filterer_partner_id=%ID%", "cog", "...");
});
As you can see in the code above, I'm just using the placeholder %ID% in every added link URL. This placeholder will be replaced by each row's specific primary key on load.

chrome_LSGKWzK8Ov.png
chrome_LSGKWzK8Ov.png (7.16 KiB) Viewed 1570 times

---
Custom pages

You can also link to any other URL, for example to custom pages like this one:

Code: Select all

AppGiniHelper.TV
        .unlink()
        .addButtonOpen()
        .addLink("calculations_tree.php?SelectedID=%ID%", "align-left", "Struktur");
It is the same principle.

chrome_FC08ZGNkgl.png
chrome_FC08ZGNkgl.png (9.06 KiB) Viewed 1570 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

User avatar
cesteban
Veteran Member
Posts: 52
Joined: 2018-04-18 09:56

Re: APPGINI HELPER

Post by cesteban » 2022-12-06 19:33

Hi,

Sorry for the delay, I had to go on a trip unexpectedly, thank you very much for your support.

Regards

Post Reply