Jump to content
We've recently updated our Privacy Statement, available here ×

narcism

Members
  • Posts

    319
  • Joined

  • Last visited

Community Answers

  1. narcism's post in Subreport based on JSON source doesn't show in mainreport was marked as the answer   
    Step #1. Use an empty queryString in your subreport. You are going to pass the data(the routes array) straight from the main report.
    <queryString language="JSON"> <![CDATA[]]></queryString>[/code]Make sure you recompile the subReport so that the mainReport picks up the new one.
    Step #2. In the main report, set the subReport's  dataSourceExpression by subDataSource-ing the report dataSource with the "routes" path:
    <subreport> <reportElement x="0" y="19" width="555" height="207" uuid="0e5f93b0-ab4d-4538-ac8f-3c10b85e36e2"/> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("routes")]]></dataSourceExpression> <subreportExpression><![CDATA["Simple_Blue_Routes.jasper"]]></subreportExpression></subreport>[/code]You should be able to use the same approach from the routes subReport to pass down the "tasks" array to a deeper subReport.
  2. narcism's post in Create the same report but whit multiple DataSource (XML) was marked as the answer   
    Yes, it is possible to achieve what you want. The best way is to use the JasperReports API programmatically.
    But first you need to adjust the report template so that you pass your XML file by parameter: <parameter name="net.sf.jasperreports.xml.source" class="java.lang.String">  <defaultValueExpression><![CDATA["path/to/data.xml"]]></defaultValueExpression></parameter> Then, for the tool-ing part you could simply resort to the JasperReports sample running mechanism or get inspiration from there. For example, the XML Data Source Sample (https://github.com/Jaspersoft/jasperreports/tree/master/jasperreports/demo/samples/xmldatasource), when run with  the "ant javac compile fill pdf" command, it will:1. compile the Java code from the src folder2. compile the report templates from the reports folder3. fill the compiled reports4. export to pdf the filled reports You could modify the filling part and pass your "net.sf.jasperreports.xml.source" parameter(also holded by the JRXPathQueryExecuterFactory.XML_SOURCE constant) instead of the XML_DATA_DOCUMENT one, here: https://github.com/Jaspersoft/jasperreports/blob/master/jasperreports/demo/samples/xmldatasource/src/XmlDataSourceApp.java#L104
  3. narcism's post in Problem passing a variable from subdataset to MainDataset was marked as the answer   
    1. Set the MainDataset variable's Calculation to "System" to preserve the value you return from the subDataset.
    2. Depending where you use the variable, set the Evaluation Time for the textField showing it to something other than "Now", like "Report" or "Band".
  4. narcism's post in how to create function in the description field (Json) was marked as the answer   
    XPATH and JSON/JSONQL query languages are not compatible in terms of functions/syntax. Please refer to the documentation for the JSON/JSONQL datasource samples for more details:
    JSONQL: http://jasperreports.sourceforge.net/sample.reference/jsonqldatasource/index.html#jsonqldatasource
    JSON: http://jasperreports.sourceforge.net/sample.reference/jsondatasource/index.html#jsondatasource
  5. narcism's post in How to fill table with subdataset json ? was marked as the answer   
    This is one way to do it:
    With current JSON language:
    With the newer JSONQL language(but simpler, without the table):
  6. narcism's post in the subreport is missing page number one was marked as the answer   
    What you are experiencing is the expected behavior given your current reports(main + subreports) designs.
    If you were to set a background for each subreport element in the main report(see the attached image: yellow for 1st, purple for 2nd), you would notice that the user2 subreport, at page 2 in the main, would try to fill the remaining space but would not fit completely(but render something - its 1st actual subreport page) and would overflow on the third page of the main, which is actually the second page of the subreport.
    To fix this, you need to adjust your main report design like so:
    - adjust the second subreport element size to be at least the size of the topMargin(20px) + page header(50px) that you have in user2 subreport, to a total of at least 70px. This should force user2 subreport to overflow completely onto the next page if the engine cannot render at least the margin and the page header in the remaining space.
    - optionally, set the detail band to wrap the two subreport elements tightly. The detail band should end right after the second subreport element in order to avoid preserving unnecessary white space
  7. narcism's post in JasperReports 6.3.1 - Passing an external XML DataSource was marked as the answer   
    If you are using the same XML document in your main report and subreports, it may happen that your XML document does not reach the subreports, which may have already been compiled with JSS and contain the original XML location. You should remove that property/properties, recompile and use the following approach.
    A similar case is described in the JasperReports xmldatasource sample(http://jasperreports.sourceforge.net/sample.reference/xmldatasource/index.html#xmldatasource):
    - the XML document is parsed and passed as parameter(see the fill() method used in the sample: https://github.com/Jaspersoft/jasperreports/blob/jr-6-3-1/jasperreports/demo/samples/xmldatasource/src/XmlDataSourceApp.java#L99)
    - then, inside the main JRXML, the same parameter is passed onto the subreport to avoid parsing the document again(see the main report from the sample: https://github.com/Jaspersoft/jasperreports/blob/jr-6-3-1/jasperreports/demo/samples/xmldatasource/reports/CustomersReport.jrxml#L52)
    - you may need to consider using the date/number patterns, locale and timezone parameters if your XML contains data related to these items
  8. narcism's post in Subreport using json files was marked as the answer   
    To have this working in JasperSoft Studio(JSS):
    1. Export your data adapter from the Repository Explorer view to a file, let's say, JsonDataAdapter.xml.
    2. In the Main report, for the subreport, specify only the subreport expression:
    <subreport> <reportElement x="0" y="0" width="200" height="200" uuid="dcbf5591-7870-4d6e-9812-b373f3e03f0c"/> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"000062_sub.jasper"]]></subreportExpression></subreport>[/code]Subdatasource-ing here makes no sense since you are already under the "report62.results" path.
    3. In the Subreport report add this property:
    <property name="net.sf.jasperreports.data.adapter" value="path/to/JsonDataAdapter.xml"/>[/code]with the proper value to the JsonDataAdapter. xml from step #1 and recompile.
    You need this property because JSS will not provide an adapter for the subreport. 
    You might also need to set this property in the Main report when deploying it, unless JSS fills it for you(it might do that when deploying to a JasperReports Server).
  9. narcism's post in Background color in conditional style doesn't drawn was marked as the answer   
    You need to remove the "backcolor" atribute on the reportElement from your JRXML.
    It takes precedence over the one coming from the style.
    You can manually remove the attribute:
    in the "Appearance" tab of the textField's Properties view by right-clicking the Backcolor color box and selecting the "Set to Null" option or from the "Source" tab of your report by directly editing the JRXML
  10. narcism's post in Visualize.js: How to segregate "Report running and rendering" task into two isolated tasks "Report running in server" and "Report rendering in Visualize.js" was marked as the answer   
    It is possible to achieve what you want to a certain degree:
    1. You need to use the runImmediately option set to false in order to prevent the automatic running and rendering:
    visualize({ auth: { name: "username", password: "password", organization: "organization" } }, function (v) { var report = v.report({ resource: "/path/to/report", // container: "#container", runImmediately: false }); // step #2 }, function(err) { console.log(err.message); });
     
    Having the container property not specified may help later.
    2. Now you can just call the render function on the report object:
    report.run().done(function() { report.properties({container: "#container"}); });
    Report running and rendering are asynchronous operations on server and client meaning you will normally start seeing things as soon as they are ready.
    But the above call starts running the report on the server and prevents the rendering by not having the container property specified in the original config object. It also reinstates the container property so that a later call to the render() method will work properly.
    Having the container specified in the original report configuration object will trigger the rendering of the requested page(1 by default) as soon as it is ready. This does not mean that the whole report is in the completed state, but at least you can start seeing something. It is up to you how you want to use it.
    3. There are a couple of events that may help tracking the report status (http://community.jaspersoft.com/documentation/tibco-jasperreports-server-visualizejs-guide/v62/api-usage-report-events) but there are no fine-grained events to hook to.
    4. You could use the reportCompleted event to trigger the rendering once the report is completed.
    The final code would looke like this:
    visualize({ auth: { name: "username", password: "password", organization: "organization" } }, function (v) { var report = v.report({ resource: "/path/to/report", events: { reportCompleted: function(status, error) { if ("ready" === status) { report.render(); } } } // container: "#container", runImmediately: false }); report.run().done(function() { report.properties({container: "#container"}); }); }, function(err) { console.log(err.message); });
     
  11. narcism's post in Usage of REPORT_PARAMETERS_MAP was marked as the answer   
    Yes, this is one of the use cases for the REPORT_PARAMETERS_MAP: to have the same set of report parameters that the master report has received.
    For a subreport you use it like this:
    <subreport> ... <parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression> ...</subreport>
     
     
  12. narcism's post in How can I list the reports in a path with rest_v2? was marked as the answer   
    This is what usually works for me to get the reports from a folder:
    http://myserver:8080/jasperserver/rest_v2/resources?type=reportUnit&folderUri=/reports/myreports
  13. narcism's post in switch off interactive features? was marked as the answer   
    Yes, you can control the interactivity features. You need to set this property:
    net.sf.jasperreports.components.table.interactive
    to false
    at any of these levels:
    column component report globally(jasperreports.properties) for all reports So, in your case, setting it at the report level should do the job.
  14. narcism's post in How to deal with JSON-List as JsonDataSource was marked as the answer   
    Hi,
    The following solution requires the jasperreports library to be at least version 5.0.4. 
    Your jrxml fragment should look like this:
    .....<field name="projectName" class="java.lang.String"> <fieldDescription><![CDATA[project.name]]></fieldDescription></field>....<subreport> <reportElement x="0" y="72" width="554" height="98" isRemoveLineWhenBlank="true" backcolor="#FFCC99" uuid="4eb7e220-6758-465f-83c9-45cdfecc33eb"/> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("persons")]]></dataSourceExpression> <subreportExpression><![CDATA["jsonPerson.jasper"]]></subreportExpression> </subreport>[/code]and in your subreport you should discard the usage of the JsonDataSource parameter.
    Hope this helps,
    Narcis
  15. narcism's post in disable table filtering/sorting (headertoolbar) in JRS 5.5 was marked as the answer   
    In jasperreports there is a boolean property that controls the interactivity at table and column levels:
    net.sf.jasperreports.components.table.interactive
     
    You can set it in any of these places: globally(jasperreports.properties), per report(*.jrxml), per table or per table column.
     
    This property defaults to 'true' in default.jasperreports.properties from jasperreports jar.
     
    At column level, if no property is set, the one for the table is taken into account. If the table doesn't have this property, it is taken from the report, and so forth.
    If at least one column has this property set to 'true' and the table's interactivity is turned off, the table will become interactive only for this column( or columns).
×
×
  • Create New...