{"id":30,"date":"2009-05-08T00:20:30","date_gmt":"2009-05-07T23:20:30","guid":{"rendered":"http:\/\/therobinsonfamily.net\/?p=30"},"modified":"2009-05-08T00:20:30","modified_gmt":"2009-05-07T23:20:30","slug":"ireport","status":"publish","type":"post","link":"https:\/\/therobinsonfamily.net\/?p=30","title":{"rendered":"iReport"},"content":{"rendered":"<p>I played about with iReport 3.5.1 and its new list component, it&#8217;s rather good. Here&#8217;s what I did.<\/p>\n<p>I have a report that gives food sales within a date range and groups them by the food group (Meat, Vegetables and cake, say). One thing I&#8217;ve wanted to do for a while was have the total for each group in the summary at the end of the report. <!--more-->To save you looking through to find page 12 and the total for a group that may only have a few items in it. You could do this with complicated &#8220;if, then&#8221; statements in report fields or a fiddly subreport, but now you can use the List.<\/p>\n<p>First drag the list component to the summary band. This causes an expected rectangle to appear on the page, and a  &#8220;Component&#8221; stub to appear in the report inspector, but this isn&#8217;t where you need to start, for a new section has been created in the Report Inspector called dataset1. Its underneath the scriptlets section (with the coffee mug icon, see it?)<\/p>\n<p>Clicking the + to expand the dataset1 tree brings up the subsections Parameters, Fields, Variables and Groups. The first three we are familiar with and gives us the first clue we are working on a report within a report.<\/p>\n<p>Right clicking on the dataset1 stub brings up a context menu. In it we can see that equally familiar option &#8220;Edit Query&#8221;  option. Clicking on it takes us to the Report Query window and we can Query to our hearts content.<\/p>\n<p>Just like the main report the fields are automatically generated for us, so for us who use SQL we can merrily SELECT some,columns FROM a.table<\/p>\n<p>Back in the dataset1 stub the sub-entry Fields has some things we can drag into our Component.<\/p>\n<p>Now, scooting down the the summary section and right clicking the Component brings us up a context menu with &#8220;Edit list datasource&#8221; at the top. Sources for data are vital if you don&#8217;t want boring nulls everywhere. Clicking it brings up a window which tells us which dataset we are using (dataset1) and three tabs, the first two are parameters which we&#8217;re not using so lets skip right on to the clumsily named &#8220;Connection\/Datasource exp&#8221; (I can&#8217;t read exp without thinking experience, sorry)<\/p>\n<p>Its default is set to &#8220;Use datasource expression&#8221; which I&#8217;m guessing means we can create a datasource link to an entirely separate DB to the one the main report is using, pretty awesome stuff but overkill for what I want. The report already has a datasource and I want to use that. Clicking on the combo box gives us the option of &#8220;Use connection expression&#8221; which does exactly what I want so lets use that.<\/p>\n<p>Now we can run the report. Yes, thats all there is to it. Passing parameters to a list from the main report is as simple as setting up parameters in dataset1 and it&#8217;s query, then matching them up using the Components &#8220;Edit list datasource&#8221; and that first tab we saw.<\/p>\n<p>Easy as eating pancakes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I played about with iReport 3.5.1 and its new list component, it&#8217;s rather good. Here&#8217;s what I did.<\/p>\n<p>I have a report that gives food sales within a date range and groups them by the food group (Meat, Vegetables and cake, say). One thing I&#8217;ve wanted to do for a while was have the total for each group in the summary at the end of the report. to save you looking through to find page 12 and the total for a group that may only have a few items in it. You could do this with complicated &#8220;if, then&#8221; statements in report fields or a fiddly subreport, but now you can use the List.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[20,24],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-software","tag-ireport","tag-software"],"_links":{"self":[{"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":0,"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/therobinsonfamily.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}