All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Report Designer Integration (npm or Yarn Package Managers)

  • 4 minutes to read
NOTE

The complete sample project How to Perform the JavaScript Report Designer Integration (with npm or Yarn package managers) is available in the DevExpress Examples repository.

You can use the End-User Web Report Designer in JavaScript based on the server-side model. You should create two projects:

  • server (backend) project that enables Cross-Origin Resource Sharing] and retrieves a report from the storage
  • client (frontend) part that includes all the necessary styles, scripts, and HTML-templates.

Server (Backend) Part

Perform the steps from one of the following topics to prepare a backend application:

Client (Frontend) Part

The following steps describe how to configure and host the client part:

  1. Create a new folder to store the client-side files (ClientSide in this example).

  2. Create the text file package.json in the ClientSide folder with the following content:

    {
        "name": "report-designer-example",
        "dependencies": {
            "devextreme": "20.1.*",
            "devexpress-richedit": "20.1.*",
            "@devexpress/analytics-core": "20.1.*",
            "devexpress-reporting": "20.1.*",
            "jquery-ui-dist": "^1.12.1",
            "ace-builds": "^1.3.3"
        }
    }
    
    NOTE

    Frontend and backend applications should use the same version of DevExpress controls.

    TIP

    The devexpress-richedit package enables the Rich Text Editor for the XRRichText control. You can exclude the package to reduce the node_modules folder size.

  3. Ensure that you have npm or Yarn package managers installed. Package manager are required to download all the necessary client resources to the node_modules folder.

  4. Open the command prompt, navigate to the client application root folder (ClientSide) and run the command:

    • if you have npm:
      npm install
      
    • if you have yarn:

      yarn install
      
  5. Create the index.html file in the root folder. It is the View file in our model. Copy the following HTML code and insert it in this file:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    
        <link href="node_modules/jquery-ui-dist/jquery-ui.min.css" rel="stylesheet" />
        <script src="node_modules/jquery/dist/jquery.min.js"></script>
        <script src="node_modules/jquery-ui-dist/jquery-ui.min.js"></script>
    
        <script src="node_modules/knockout/build/output/knockout-latest.js"></script>
    
        <!--Link DevExtreme resources-->
        <script src="node_modules/devextreme/dist/js/dx.all.js"></script>
        <link href="node_modules/devextreme/dist/css/dx.common.css" rel="stylesheet" />
        <link href="node_modules/devextreme/dist/css/dx.light.css" rel="stylesheet" />
    
        <!-- Optionally (for intelligent code completion in the Expression Editor and Filter Editor) -->
        <script src="node_modules/ace-builds/src/ace.js"></script>
        <script src="node_modules/ace-builds/src/ext-language_tools.js"></script>
        <script src="node_modules/ace-builds/src/snippets/text.js"></script>
        <!--  -->
    
        <!-- Link Rich Edit scripts and styles between DevExtreme and Reporting links -->
        <script src="node_modules/jszip/dist/jszip.min.js"></script>
        <script src="node_modules/devexpress-richedit/dist/dx.richedit.min.js"></script>
        <link href="node_modules/devexpress-richedit/dist/dx.richedit.css" rel="stylesheet" />
    
        <!-- Link the Reporting resources -->
        <script src="node_modules/@devexpress/analytics-core/dist/js/dx-analytics-core.js"></script>
        <script src="node_modules/@devexpress/analytics-core/dist/js/dx-querybuilder.js"></script>
        <script src="node_modules/devexpress-reporting/dist/js/dx-webdocumentviewer.js"></script>
        <script src="node_modules/devexpress-reporting/dist/js/dx-reportdesigner.js"></script>
        <link href="node_modules/@devexpress/analytics-core/dist/css/dx-analytics.common.css" rel="stylesheet" />
        <link href="node_modules/@devexpress/analytics-core/dist/css/dx-analytics.light.css" rel="stylesheet" />
        <link href="node_modules/@devexpress/analytics-core/dist/css/dx-querybuilder.css" rel="stylesheet" />
        <link href="node_modules/devexpress-reporting/dist/css/dx-webdocumentviewer.css" rel="stylesheet" />
        <link href="node_modules/devexpress-reporting/dist/css/dx-reportdesigner.css" rel="stylesheet" />
    </head>
    <!-- ... -->
    </html>
    
    NOTE

    The requirements and resources to deploy the control on the client are described in the Report Designer Requirements and Limitations document.

  6. Create the example.js file in the root folder to provide data to the View. The JavaScript code in this file creates the designerOptions variable and activates the Knockout bindings. Copy the following code and insert it in the example.js file:

    
    const host = 'http://localhost:54111/',
        reportUrl = "Products",
        designerOptions = {
            reportUrl: reportUrl, // The URL of a report that the Report Designer loads when the application starts.  
            requestOptions: { // Options for processing requests from the Report Designer. 
                host: host, // URI of your backend project.
                invokeAction: "/ReportDesigner/Invoke", // Action to enable CORS.
                getDesignerModelAction: "/ReportDesigner/GetReportDesignerModel" // Action that returns the Report Designer model. 
            }
        }
    
    ko.applyBindings({ designerOptions });
    
  7. Modify the index.html file to specify the HTML template that uses the dxReportDesigner binding with the designerOptions parameter. Add the following code to the body section:

    ...
    <body>
        <div style="width:100%; height: 1000px" data-bind="dxReportDesigner: designerOptions" ></div>
        <script type="text/javascript" src="example.js"></script>
    </body>
    
  8. Host the client-side part on the web server. 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 client-side application root folder, and the website's IP address and port.

    host-javascript-example-in-iis

  9. Run the backend project in Visual Studio.

  10. Open the website, created in the step 8, in the browser. In this example the address is http://localhost:1000 .