Adhoc View - Change default report option

Issue Description

In TIBCO JasperReports® Server v6.0.1, once we select the data sets for the adhoc view and the system shows the fields, the default option for the creation of adhoc view is set to cross tab.

How can we change this to default to Table?


Resolution

JasperReports Server v6.0.1

  • In 6.0.1 You can modify the following file to set the default report type option to another type (valid types are table, chart, and crosstab):

    jasperserver-pro\scripts\bower_components\jrs-ui\src\actionModel.primaryNavigation.js

  • In this file you should see the following:

    designer: {
        url :    "flow.html",
        params : "_flowId=adhocFlow"
    }
  • Append &reportType=table to it i.e.

    designer: {
        url :    "flow.html",
        params : "_flowId=adhocFlow&reportType=table"
    }

JasperReports Server v6.2.x, 6.3

  • In 6.2.x and 6.3.0 you can modify the following file to set the default report type option to another type (valid types are table, chart, and crosstab):

    \jasperserver-pro\scripts\adhoc\datachooser\view\DatachooserDialogView.js

  • Find the original line below (near line 95 or 97 depending on version), and change it to reflect "table" instead of "crosstab"

    reportType = reportType || "crosstab";

Applying changes to your system:

Testing phase:

During this phase we will disable JavaScript optimization.

This step is done to see the result of our modification immediately.

To disable JavaScript optimization please do the adjustment below:

  • Set the javascript.optimize property to false in the file, jasperserver-pro\WEB-INF\js.config.properties.

    # Control default value of javascript optimization in runtime
    javascript.optimize=false
  • Shut down JasperReports Server web application.

  • Delete the application server cache.

  • Restart the server.

Applying changes permanently:

Disabling JavaScript optimization in the previous step was done only to test our customization. Usage of non-optimized JavaScript code is not recommended and may cause performance degradation and other undesirable problems.

To apply the working solution in the production:

  • Rebuild JavaScript code according to the detailed instruction that you can find in the JasperReports Server Ultimate Guide, Customizing JavaScript files chapter

  • Set JavaScript optimization to true:

    # Control default value of javascript optimization in runtime
    javascript.optimize=true
  • After this Application Server should be restarted again to apply the changes to the modified version of optimized JavaScript files


JasperReports Server v6.4.x, 7.1

  • Follow instructions above for 6.3 to modify the non-optimized js file (DatachooserDialogView.js).
  • The location of this functionality for the optimized javascript file has changed, therefore applying global optimizations after modifying the non-optimized file above will not work for this change.
  • To modify the optimized javascript, edit (very carefully) the optimized file: \jasperserver-pro\optimized-scripts\adhoc\adhocStartMain.js
  • Search for "crosstab" and replace the first occurance with "table" - it might look something like: o=o||"crosstab"
  • Save the file. Even though this is a javascript change, you sometimes may need to clear browser cache, your tomcat temp and/or work folders, and even possibly restart the server to see the change work.

MJB


To change the default option from Sample Data, follow instructions here: https://community.jaspersoft.com/questions/958416/adhoc-view-change-default-nodata-option


Ref. Case 00060270

Feedback
randomness