Page 1 of 1

Add a Table View Button - A little help soon please

Posted: 2020-05-06 10:58
by sathukorala
I have managed to add a "batch actions" button like shown in 1.png
1.png
1.png (8.64 KiB) Viewed 3987 times
I want to add a button like shown in 2.png
2.png
2.png (15.8 KiB) Viewed 3987 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?

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

Posted: 2020-05-06 11:11
by jsetzer
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

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

Posted: 2020-05-06 11:28
by sathukorala
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?

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

Posted: 2020-05-06 14:39
by sathukorala
Somebody a little help please.....

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

Posted: 2020-05-07 01:40
by sathukorala
Anybody a little hand for me please........... :( :( :( :( :(

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

Posted: 2020-05-07 07:07
by sathukorala
Somebody a little help please.....

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

Posted: 2020-05-08 08:11
by sathukorala
Anybody a little hand for me please....

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

Posted: 2020-05-08 09:59
by jsetzer
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.

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

Posted: 2020-05-08 12:42
by sathukorala
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.