show all parent and all related child records

Questions and answers for designing and implementing forms in Servoy

show all parent and all related child records

Postby wes.s.grayson » Sun Apr 06, 2014 10:42 pm

I would like a form that shows all parent and child records in an easy to read format that can be printed or opened in PDF. Let's say my two tables are "States" and "Cities". I would like for the form to look like this.

Alabama
Birmingham
Montgomery
Mobile
Huntsville

Arkansas
Conway
Fort Smith

Arizona
Goodyear

I can do this with tabpanels, but since each state will have a different number of city records, and since Print Sliding apparently doesn't work on tab panels, there would be large gaps of dead space on some pages.

Currently I have a form in List View based on the Cities table. I can put the State name in the header, but all the cities print out under one state. How can I show all States and all related cities? (I've tried to download Jasper Reports and Velocity but both were over my head so I'm trying to do this the simplest way within Servoy).

thanks!
wes.s.grayson
 
Posts: 46
Joined: Mon Jan 23, 2012 5:39 pm

Re: show all parent and all related child records

Postby mboegem » Sun Apr 06, 2014 11:40 pm

Hi Wes,

the way to do this, is to create a print layout based on the city table.
Then have a sub summary band containing the related state.
Before printing you should sort the city table on state(id) in order to have all cities printed by state.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1748
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: show all parent and all related child records

Postby wes.s.grayson » Mon Apr 07, 2014 12:44 am

thanks for the reply. Based on that, I created a form in List view based on cities (datasouce: city). I added a Header, Leading Subsummary, and Body. On the onShow command for the form I added

Code: Select all
controller.sort(state_id)

For the Leading Subsummary, on the Parts tab, I added a Group-By field as state_id. I wasn't sure whether this should be "state_id" from the city table, or the related field from the state table "city_to_state.state_id". I tried it both ways.

On the form, in the Leading Subsummary band I added the field state_id and the related field city_to_state.state_name.

In the body I added city_name.

The result is I see all the city names listed together and don't see any state names, or anything else from the subsummary band displayed on the form or in the Print Preview. Where did I go wrong?

thank you!
wes.s.grayson
 
Posts: 46
Joined: Mon Jan 23, 2012 5:39 pm

Re: show all parent and all related child records

Postby wes.s.grayson » Mon Apr 07, 2014 1:08 pm

I think I found my mistake. The sort should have been

Code: Select all
controller.sort('state_id')

I'm now seeing the desired result. thank you!
wes.s.grayson
 
Posts: 46
Joined: Mon Jan 23, 2012 5:39 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 3 guests