How to do a grandparent parent child page

How to do a grandparent parent child page

Hi, I'd like to do something with multiple levels of related records. Here's an example of what I'd like - the scenario is that there would be a list of companies, each company has related orders, and each order has order line items.

Showing a list of companies is easy - when someone clicks on a company, I want a page which shows the company details at the top, then shows related orders below (which also is easy), but I want each order to then list the related order line items under it.

I can't work out how to show the order line items - can anyone explain what widgets and code I would need for this?

Here's a text mockup of what the Company_Show page should look like:

Company name: Smiths plc

Order 1
Order line item 1
Order line item 2
Order line item 3
Order 2
Order line item 1
Order line item 2
Order 3
Order line item 1
Order line item 2
Order line item 3

Hopefully someone can help with that - thanks a lot!
  1. Create a web page using a Table or List Record List ... The records that will be shown in this list will be your Companies.  I prefer using the list element because I can use bolder formatting to diferentiate from the order blocks.  (maybe
  2. Create a web block, passing in the company id.  Create a table with the order records and filter using the company id.
  3. Go back to your original web page and add the new web block ... pass in the "Current" table company id value.
You may want to add addtional formatting to the web block so that the number of records / navigation only shows if the Query.Count > TableRecord.LineCount (usually 50) ... this puts a lot less information on the screen.  You can also "hide" the table header if the fields are meaningful (they will be repeated for each company if you don't).  You may also want to set a fixed width on the columns so that everything lines up correctly.  Since the data will be in seperate tables, sometimes it tends to be skewed.
Hi Rebecca, thanks for that - I've not used web blocks before, so that was really useful.

What I wanted to check was how intensive this approach is with the database queries it generates - is each web-block triggering an additional SQL query to be run? If so, a page could be having quite a lot of queries running (especially if you had web blocks nested in other web blocks).

I'm just wondering about performance, and I wanted to be clear how it works behind the scenes.

Where you've used this in practice, how have you found this approach?

Thanks a lot!

It is going to run the queries for each web block. 

Ways to optimize the code:

  • Reduce the number of top level records being shown (the default is 50, maybe 20-30 or less would be better)
  • Add List Late Load to the web block.  The top level categories would load quickly and then the child data comes in after the page is loaded.

If there is only one child web block being loaded per top level category, I haven't seen too many issues with performance by reducing how many records are being displayed.  If you are loading additional web blocks per top level category your page could slow down quickly.

Thanks Rebecca - the List_LateLoad was another new one on me, I'm learning lots with this!
I'm trying to use this technique, but can't figure out how to place the web block so it falls below the line in the List Table. The only place it lets me put it is in a new column; how do I declare a new row for it?

If you are using a TableRecords or ListRecords per each row you can insert a Table with two rows one with the fields and the other with the WebBlock. 
I must be really dense, cause I still don't get it. Could you provide a sample OML with a TableRecords, and the inserted 2-row table you describe?