Skip to main content
A newer version of this page is available.
All docs
V17.2

Basic Report Designer Integration in JavaScript (Using Bower)

  • 3 minutes to read

You can use the End-User Web Report Designer in JavaScript by creating two projects: a server (backend) project in ASP.NET MVC implementation and a client (frontend) part that includes all the necessary styles, scripts, and HTML-templates.

Note

Perform the steps in the Creating a Server Side for the Report Designer topic to create a backend application.

This document describes how to configure and host the client part:

  1. Create a new folder to store all the files related to the client-side functionality (for instance, name it ClientSide).
  2. Download all the necessary client resources using Bower. Add the bower.json file to the created folder and add the following code to this file:

    {
        "name": "report-designer-example",
        "dependencies": {
          "xtrareportsjs": "~17.2.3"
        }
    }
    

    Ensure that you correctly specify the required reporting controls’ version.

  3. Open the console, navigate to your application folder and run the following command:

    bower install

    After installation is completed, you can find all the libraries in the bower_components folder.

  4. Create the View file in the root folder (the index.html file in this example) and link the Bower resources in the head section.

    <head>
        <title></title>
        <link rel="stylesheet" href="bower_components/devextreme/css/dx.common.css" />
        <link rel="stylesheet" href="bower_components/devextreme/css/dx.light.css" />
        <link href="bower_components/jquery-ui/themes/base/jquery-ui.min.css" rel="stylesheet" />
        <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
        <script type="text/javascript" src="bower_components/knockout/dist/knockout.js"></script>
        <script type="text/javascript" src="bower_components/devextreme/js/dx.all.js"></script>
        <script type="text/javascript" src="bower_components/jquery-ui/jquery-ui.js"></script>
    
        <link href="bower_components/xtrareportsjs/css/report-designer-light.css" rel="stylesheet" />
        <script type="text/html" src="bower_components/xtrareportsjs/html/report-designer.html"></script>
        <script type="text/javascript" src="bower_components/xtrareportsjs/js/dx-designer.js"></script>
        <script type="text/javascript" src="bower_components/xtrareportsjs/js/report-designer.js"></script>
        <script type="text/javascript" src="bower_components/xtrareportsjs/js/localization/report-designer.en.js"></script>
    </head>
    

    Make sure that you meet all the requirements for deploying the control on the client. Refer to Report Designer Requirements and Limitations for a list of necessary client resources.

    Note that this sample uses a script with a predefined localization dictionary.

  5. Add the JavaScript file (example.js) to provide the required data to the View. Create the designerOptions variable and activate the Knockout bindings.

    "use strict"
    
    const host = 'http://localhost:54111/',
        reportUrl = "Products",
        designerOptions = {
            reportUrl, // The URL of a report that is opened in the Report Designer when the application starts.  
            requestOptions: { // Options for processing requests from the Report Designer. 
                host, // URI of your backend project. 
                getDesignerModelAction: "/ReportDesigner/GetReportDesignerModel" // Action that returns the Report Designer model. 
            }
        }
    
    ko.applyBindings({ designerOptions });
    
  6. In the index.html file, specify this View’s HTML template in the body section using the dxReportDesigner binding with the designerOptions parameter.

    ...
    <body>
        <div style="width:100%; height: 1000px" data-bind="dxReportDesigner: designerOptions" ></div>
        <script type="text/javascript" src="example.js"></script>
    </body>
    
  7. Host your client-side part on the web server.

    For instance, start the Internet Information Services (IIS) Manager, right-click the Sites item in the Connections section and select Add Website. In the invoked dialog, specify the site name, path to the folder with the client-side functionality, and the website’s IP address.

    host-javascript-example-in-iis

  8. For the example to work correctly, you should first run a backend project in Visual Studio, and then, run a client part.
See Also