Add button on table view page

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Add button on table view page

Post by Moh Youba » 2019-08-28 23:04

Hello

Is it possible to add new button in table view to print custom page? if yes, please how?
button.jpg
button.jpg (62.57 KiB) Viewed 199 times
Thank you

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 211
Joined: 2013-03-21 04:37

Re: Add button on table view page

Post by peebee » 2019-08-28 23:48

Create (or use existing if you already have one) a new yourtablename-tv.js in your hooks folder (where of course yourtablename is the actual name of your table)

Example to add a new Filter button next to existing buttons. Edit the function/style to suit your purpose:

Code: Select all

jQuery(function(){
   jQuery('#Filter').after('<button class="btn btn-default" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-filter"></i> Button Label</button>');
        jQuery('button[id=filter-button]').click(function(){
              window.location = 'yourtablename_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=etc........';
        });
});
Hopefully that is a good starting point, depending on what you want your button to do?

Ref: viewtopic.php?t=1034

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 553
Joined: 2018-04-01 10:12

Re: Add button on table view page

Post by pböttcher » 2019-08-29 06:46

Hi,

just to add, you may want to append to the last button of the section (and this may be different depending on your settings).
You can use

Code: Select all

jQuery('#top_buttons .btn-group:first .btn:last') 
to catch the last button in the row.

Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Re: Add button on table view page

Post by Moh Youba » 2019-08-29 10:38

thank you for support, I added code to show button but, unfortunately nothing no button show !

button-2.jpg
button-2.jpg (38.13 KiB) Viewed 179 times

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 211
Joined: 2013-03-21 04:37

Re: Add button on table view page

Post by peebee » 2019-08-29 11:20

File name should be dossier_individuel-tv.js (for table view) - not dossier_individuel-dv.js

Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Re: Add button on table view page

Post by Moh Youba » 2019-08-29 11:26

my bad !
thank you, really appreciate the support. I usually use dv and did not see the that there is new file called tv.
Thank you for your support, button now show correctly.
Regards

Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Re: Add button on table view page

Post by Moh Youba » 2019-08-29 11:31

hummm !!!
I want now to link to a printable page, I use this code

"window.location = 'decomptes_invoice.php?iddecompte=' + selectedID;"
but seems not the one, any help please
print-page.jpg
print-page.jpg (33.38 KiB) Viewed 173 times

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

Re: Add button on table view page

Post by jsetzer » 2019-08-29 12:16

According to the url-documentation here...
https://bigprof.com/appgini/help/advanc ... parameters
...there is the Print_x parameter

Code: Select all

TABLENAME_view.php?SelectedID=...&Print_x=1
Just in case you only need to open the print-preview:
Instead of adding a <button> with a click-handler you could add a simple <a href="...">...</a>

Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Re: Add button on table view page

Post by Moh Youba » 2019-08-29 13:44

tryied different option but cannot find the right way to add the code, please help. the file I want to print "decomptes.invoice.php" is not in the hooks file.

jQuery(function(){
jQuery('#Filter').after('<button class="btn btn-default" type="button" id="foebar"><i class="glyphicon glyphicon-ok"></i> PRINT</button>');
jQuery('button[id=foebar]').click(function(){
"window.location = 'decomptes_invoice.php?SelectedID=&Print_x=1';"
});
});

Post Reply