Add a Table View Button - A little help soon please

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Add a Table View Button - A little help soon please

Post by sathukorala » 2020-05-06 10:58

I have managed to add a "batch actions" button like shown in 1.png
1.png
1.png (8.64 KiB) Viewed 3988 times
I want to add a button like shown in 2.png
2.png
2.png (15.8 KiB) Viewed 3988 times
The code I used in tablename-tv.js is

function print_treatment_card(table_name, ids){
var url = 'treatment_card.php?table=' + table_name;
for(var i = 0; i < ids.length; i++){
url = url + '&'
+ encodeURI('ids[]') + '='
+ encodeURIComponent(ids);
}

window.open(url);
}

I have tried using appgini JS library but it doesn't work.

function print_treatment_card(table_name, ids){
var url = 'treatment_card.php?table=' + table_name;
for(var i = 0; i < ids.length; i++){
url = url + '&'
+ encodeURI('ids[]') + '='
+ encodeURIComponent(ids);
}

window.open(url);
}

jQuery(function () {
var tv = new AppGiniTableView();
tv.addButton(function (id)
{
print_treatment_card();
}, "print", "Treatment Card");
// "flash" is the name of the glyphicon
// "My function" is the button text
});


Can anyone please help me soon?

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

Re: Add a Table View Button - A little help soon please

Post by jsetzer » 2020-05-06 11:11

Hi,

your function call print_treatment_card(); does not send any parameter, but your function print_treatment_card(table_name, ids) requires two parameters "table_name", and "ids".

It seems you are mixing up AppGini batch actions and javascript function calls.

Regards,
Jan
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 25.10 + all AppGini Helper tools

sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Re: Add a Table View Button - A little help soon please

Post by sathukorala » 2020-05-06 11:28

jsetzer wrote:
2020-05-06 11:11
Hi,

your function call print_treatment_card(); does not send any parameter, but your function print_treatment_card(table_name, ids) requires two parameters "table_name", and "ids".

It seems you are mixing up AppGini batch actions and javascript function calls.

Regards,
Jan
Thanks for the reply jsetzer
Even this didn't work
Can this be done with javascript function calls in another way?

jQuery(function () {
var tv = new AppGiniTableView();
tv.addButton(print_treatment_card(table_name, ids)
{
var url = 'treatment_card.php?table=' + table_name;
for(var i = 0; i < ids.length; i++){
url = url + '&'
+ encodeURI('ids[]') + '='
+ encodeURIComponent(ids);
}

window.open(url);
}, "print", "Treatment Card");
// "flash" is the name of the glyphicon
// "My function" is the button text
});


Can this be done with javascript function calls in another way?





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

Re: Add a Table View Button - A little help soon please

Post by jsetzer » 2020-05-08 09:59

I have explained everything you need here:
https://appgini.bizzworxx.de/appgini-he ... ngle-rows/

You only need soma basic Javascript knowledge to apply the code shown there to your specific function.
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 25.10 + all AppGini Helper tools

sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Re: Add a Table View Button - A little help soon please

Post by sathukorala » 2020-05-08 12:42

jsetzer wrote:
2020-05-08 09:59
I have explained everything you need here:
https://appgini.bizzworxx.de/appgini-he ... ngle-rows/

You only need soma basic Javascript knowledge to apply the code shown there to your specific function.
Thank you so much jsetser.
You are a lifesaver.
I finally did that.

Post Reply