Building reports

97 views
Skip to first unread message

Christopher Roque

unread,
Aug 6, 2022, 11:53:38 AM8/6/22
to Jam.py Users Mailing List
hi, i'm new with jam-py any guide on how to build a report? i cant get it working with the codes on the server side.

Drazen D. Babic

unread,
Aug 6, 2022, 1:54:25 PM8/6/22
to Jam.py Users Mailing List
Hi

it depends on your data. Not easy to advice if no context.

What is the issue?


Christopher Roque

unread,
Aug 7, 2022, 1:33:52 AM8/7/22
to Jam.py Users Mailing List
i made a simple data to extract firstname,middlename and lastname, i already uploaded the ods file with column A,B,C on the server, sorry i'm new with jam-py and and a little coding, but ive used a msaccess before.
Screenshot_7.jpg
Screenshot_1.jpg

Drazen D. Babic

unread,
Aug 7, 2022, 3:14:15 AM8/7/22
to Jam.py Users Mailing List
I think you are on the right track, just study the Demo a bit. Create an report and use the Server report code for your example as in the Documentation or Demo.
It also depends on if using Windows or Linux.
Coming from Access youll see that Jam is not using SQL for reports, as in server_side_programming.html Doco.
It is also using just a few report.print_band(...) to actually print stuff!
It might be a daunting task at first but really is a copy and paste and changing it a bit as you go. 

Danijel Kaurin

unread,
Aug 7, 2022, 6:01:58 AM8/7/22
to Jam.py Users Mailing List
Hi.

If you want to print all records,  name your report: profile_report and paste this code on report server module:

def on_generate(report):
    profile= report.task.profile.copy()
    profile  .set_order_by('lastname')
    profile  .open()

    report.print_band('title')

    for c in  profile  :
        firstname = c.firstname.display_text
        middlename= c. middlename  .display_text
        lastname = c.lastname.display_text
        report.print_band('detail', locals())

Note: in .ods template, you need to add word "detail" in A column where yor record will be printed. That's why you have problem in your report.

and then this code in profile item client module (call this functions on some view button):

function print(item) {
    task.profile_report.print(false);
}

...

If you want to print report based on selected profiles in view form, you need to add report parameter "id" and use this code in report server module:

def on_generate(report):
    profile= report.task.profile.copy()
    if report.id.value:
         profile  .set_where({'id__in': report.id.value})
    profile  .set_order_by('lastname')
    profile  .open()

    report.print_band('title')

    for c in  profile  :
        firstname = c.firstname.display_text
        middlename= c. middlename  .display_text
        lastname = c.lastname.display_text
        report.print_band('detail', locals())

and this code in profile item cliend module (you need to pass selected id's):

function print(item) {
let selections = item.selections;
     if (selections.length === 0) { 
         selections = [item.id.value]; 
         }
    task.profile_report.id.value = selections;
    task.profile_report .print(false);
}

Regards

Danijel Kaurin

Dean D. Babic

unread,
Nov 14, 2023, 11:11:29 PM11/14/23
to Jam.py Users Mailing List
Hi, 
just making this thread alive again if anyone is interested in the building reports.
This thread:


is well worth visiting for extracting needed information from any database. 
Just hook Jam to your DB of choice, import needed tables and create a Pivot to start analyzing data.
Obviously, new Pivot is needed for different  stuff. The PDF report is more professional, but this is fast 
and drag/drop.


Enjoy

Reply all
Reply to author
Forward
0 new messages