create master-detail form

440 views
Skip to first unread message

Fabio Lenzarini

unread,
Feb 19, 2021, 1:00:11 PM2/19/21
to Jam.py Users Mailing List
Hi,
I have 2 tables, created as "catalogs":
customers
projects
2021-02-19 18_55_00-Application builder.png
related to each other by the field "customerId".

I am trying to create a master-detail form:
above customers
below projects

I followed the example on the demo, but I don't understand where I'm going wrong...

2021-02-19 18_55_43-Application builder.png

thanks
Fabio

Fabio Lenzarini

unread,
Feb 19, 2021, 1:17:28 PM2/19/21
to Jam.py Users Mailing List
I've read:

But I think the error is on
item.invoice_table.create_table(item.view_form.find('.view-detail')
I think ".view-detail" is wrong...



--
You received this message because you are subscribed to a topic in the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jam-py/rj0VuRqdYk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/cbef3703-a3f8-499a-8832-8da6be5f9991n%40googlegroups.com.

Dražen Babić

unread,
Feb 19, 2021, 8:33:57 PM2/19/21
to Jam.py Users Mailing List
Hi,

There is no need for ANY code to have master-detail.
If u search this group it was discussed how to link two tables.


D.


You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/CAFnDzjNeiKKkUN6%2B5-%2Beaw4AUKr1oOO-U9YN7%2Bnyv65YB6%2BvXA%40mail.gmail.com.

Dražen Babić

unread,
Feb 19, 2021, 9:28:30 PM2/19/21
to Jam.py Users Mailing List
What I would suggest is to search for "Making Master-Detail from existing non-Jam created tables" in here - which touches a missing links like in your scenario. We all been there...

One Jam pie thrown :)

On Sat, 20 Feb 2021, 02:17 Fabio Lenzarini, <fabio.l...@gmail.com> wrote:
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/CAFnDzjNeiKKkUN6%2B5-%2Beaw4AUKr1oOO-U9YN7%2Bnyv65YB6%2BvXA%40mail.gmail.com.

Fabio Lenzarini

unread,
Feb 20, 2021, 3:54:33 AM2/20/21
to Jam.py Users Mailing List
Sorry, I'm dumb..
the projects table is related to the customer table.

2021-02-20 09_43_59-Window.png

I thought the relationship was retrieved automatically.

what should i do?

i don't want to move the table to the task details...

2021-02-20 09_40_19-Window.png

I've the table, but are empty..

I need to set manually the relation?

function on_view_form_created(item) {
    if (!item.lookup_field) {
        item.table_options.height -= 200;
        item.projects = task.projects.copy();
        item.projects.paginate = true;
        item.projects.create_table(item.view_form.find('.view-detail'), {
            height: 200,
            summary_fields: ['projectid'],
            on_dblclick: function() {
                show_projects(item.projects);
            }
        });
        item.alert('Double-click the record in the bottom table to see the invoice in which the track was sold.');
        item.table_options.multiselect = true;
  
    }
}
thanks
Fabio

Dražen Babić

unread,
Feb 20, 2021, 5:50:58 AM2/20/21
to Jam.py Users Mailing List
No worries,

What u need to do is to LINK this two tables. If not linked already.
How to link? Look at the Demo Invoices.
There is a Details option there, it is selected for Tracks.
Now, do you have this selected for your tables?

It is not the code. Code comes after. 
Also, Andrew posted video for Master-Details on youtube.

There are number of other demos, visit:

Hope this helps.

Andrew Yushev

unread,
Feb 20, 2021, 11:09:24 AM2/20/21
to Dražen Babić, Jam.py Users Mailing List
Hi, Fabio

In the example from docs
there is an on_after_scroll event handler that is triggered when
master record changes and it calls the open method to get detail records.

function on_after_scroll(item) {
    if (item.view_form.length) {
      if (item.rec_count) {
          item.invoice_table.set_where({track: item.id.value});
          item.invoice_table.set_order_by(['-invoice_date']);
          item.invoice_table.open(true);
      }
      else {
          item.invoice_table.close();
      }
    }
}

Replace item.invoice_table with item.projects in this code, track with customerId and change a field in set_order_by.

Regards,
Andrew Yushev





сб, 20 февр. 2021 г. в 13:50, Dražen Babić <bab...@gmail.com>:

Drazen D. Babic

unread,
Feb 20, 2021, 10:57:27 PM2/20/21
to Jam.py Users Mailing List
I think there is a missing link in here:

2021-02-19 18_55_43-Application builder.png

When we create Tables in catalogs, there is no master_rec_id. So there is no link. What is the link? Probably projects.customerid.value and not master_rec_id in above code.
Hence on_after_scroll won't help here, since the link is missing.

This is also a Jam paradigm, there is a Master->Details for Editing, and the Master->Details for Showing only. 

So I think this link https://jam-py.com/docs/how_to/how_to_link_two_tables.html is a bit misleading, because it looks almost the same as proper Master->Details Invoices,
however, it is for Displaying the Details only.

As mentioned in "Making Master-Detail from existing non-Jam created tables" thread - master_rec_id is the special Jam feature used only for Editing the Master-Details.

D.

Fabio Lenzarini

unread,
Feb 21, 2021, 9:13:12 AM2/21/21
to Jam.py Users Mailing List
Thank you for all the support.
Now work fine!

In a few days I think to post my sample app as example.

On the while, I-ve changed idea for the table structure and the interface..

Fabio Lenzarini

unread,
Feb 21, 2021, 9:13:23 AM2/21/21
to Jam.py Users Mailing List
thanks Andrew, thanks Drazen.
Now the master detail work!


Il giorno domenica 21 febbraio 2021 alle 04:57:27 UTC+1 Drazen D. Babic ha scritto:
Reply all
Reply to author
Forward
0 new messages