Print with only some fields

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
stefdefrance
Posts: 14
Joined: 2014-12-05 18:34

Print with only some fields

Post by stefdefrance » 2018-12-15 21:16

Hello everybody (from France)

I have a question for you... I didn't findd the right answer in the forum :
- I would like to print some tables view with the printing button but I want to have only 4 fields of the table onthe printed page.

In my mind there are different possibilities

- Working with hook but I'm not a very good codeur
- Changing the DVP file
- Creating a second table wich is similar of the parent table with only the specifics fields.

I prefer the last solution but I don't know how to do it

Thanks for your help

hubert
Veteran Member
Posts: 50
Joined: 2018-12-06 22:32

Re: Print with only some fields

Post by hubert » 2018-12-19 08:10

Hi Stef,
may be check the invoice course on Udemy or you could work with FPdF where you can fully parameter your print template.

User avatar
a.gneady
Site Admin
Posts: 1309
Joined: 2012-09-27 14:46
Contact:

Re: Print with only some fields

Post by a.gneady » 2018-12-19 20:41

Here is a suggested solution without creating a new table or editing generated files ... in the hooks/footer-extras.php file, add this code:

Code: Select all

<script>
    $j(function() {
       // change 'tablename' below to the name of the concerned table
       if(location.href.match(/tablename/) == null) return;

       // change the number '4' below to the index of the field you want to hide when printing .. first field is 0
       // and repeat this line for each field you want to hide
       $j('div.form-group').eq(4).addClass('hidden-print');
    })
</script>
You can test your code by opening the print preview of the page fromt he browser menu.
:idea: AppGini plugins to add more power to your apps:

stefdefrance
Posts: 14
Joined: 2014-12-05 18:34

Re: Print with only some fields

Post by stefdefrance » 2019-01-26 11:19

Hello to you all

In fact, I've found the answer. With the new possibilities of appgini we can choose the fields we want to see and so the fields we want to print...

I love AppGini !!!!

SkayyHH
Veteran Member
Posts: 459
Joined: 2015-04-27 21:18

Re: Print with only some fields

Post by SkayyHH » 2024-05-25 06:35

Hi Ahmed,

please, how can i hide the fields from the print preview view too? The code hides only hides the fields in the final print dialog.

Thank you very much.

SkayyHH
Veteran Member
Posts: 459
Joined: 2015-04-27 21:18

Re: Print with only some fields

Post by SkayyHH » 2024-05-25 06:58

This will also not work for me (from appgini-customization-cookbook):

hooks/tablename-dv.js :

$j(function() {
// set the contents of this array to the indexes of fields to hide
// 1st field is 0, 2nd is 1, ... etc.
var hide = [2, 5, 7];

// don't edit below here!
// execute this only in print-preview
if(!$j('#print').length) return;
hide.map(function(i) { return $j('.form-group').eq(i).addClass('hidden'); });
})

Thank you very much.

SkayyHH
Veteran Member
Posts: 459
Joined: 2015-04-27 21:18

Re: Print with only some fields

Post by SkayyHH » 2024-05-25 07:16

I I have it now. It works though. :-)

SkayyHH
Veteran Member
Posts: 459
Joined: 2015-04-27 21:18

Re: Print with only some fields

Post by SkayyHH » 2024-05-25 07:26

Like that:

In hooks/tablename-dv.js :

function dv(table, id, view) {
$j(function() {
if ($j('#print').length === 0) return;

var hide = [0, 1, 5];

hide.forEach(function(index) {
$j('.form-group').eq(index).addClass('hidden');
});
});
}

Post Reply