Hide custom action button

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Hide custom action button

Post by pfrumkin » 2021-04-27 17:16

Hi,

I have implemented a custom button using the actionbuttons.group.addbutton method. I need to hide it in some cases, once it is added how can I hide it?

Thanks.

~Paul
AG 5.84

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

Re: Hide custom action button

Post by jsetzer » 2021-04-27 18:14

You can use the return value of addButton function:

Code: Select all

var dv = AppGiniHelper.dv;
var grp = dv.getActionButtons().addGroup("Group (1)");
var btn = grp.addButton("Button (1)", function (e) {  /* your fn */ });

console.log("id of button: " + btn.id);
chrome_tJ1CPmCNOR.png
chrome_tJ1CPmCNOR.png (4.73 KiB) Viewed 2245 times

Console output:

chrome_yzXWKUm1eK.png
chrome_yzXWKUm1eK.png (2.43 KiB) Viewed 2245 times

--
Later on, you can use the id for accessing the button by id:

Code: Select all

var hide_button = true; // your condition

if (hide_button)
    jQuery(`#${btn.id}`).hide();
PS: the id's will not persist between page loads
PPS: you can also get the id of the group and access the group element
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

pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Hide custom action button

Post by pfrumkin » 2021-04-27 20:31

Awesome, thanks Jan! :D

To hide I had to use

Code: Select all

$j("#" + btn.id).hide();
~Paul

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

Re: Hide custom action button

Post by jsetzer » 2021-04-27 20:40

Yes, string concatenation with + in javascript will work, too.

The `${variable}` notation seems new to many javascript developers. I don't see it very often. For me this is very useful and I got used to using that template-like string building instead of + concatenation.
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

Post Reply