Add form on page

Posted by: bnguyen on 12 January 2024, 7:58 am EST

    • Post Options:
    • Link

    Posted 12 January 2024, 7:58 am EST

    Is it possible to add a form onto a page where the user enters the parameter with RDL report?

    Similar to HTML Form

  • Posted 14 January 2024, 8:44 pm EST

    Hi Bryan,

    Yes, you can set the Parameter added to your RDL report as Hidden and add a form on the page, and on the onclick event of the button, you can use the parameter value to open the report using the openReport method of JSViewer API. You may refer to the following code sample:

    <body>
        <div>
            <label for="lblcustomerID">Enter Customer Id:</label>
            <input type="text" id="lblcustomerID">
            <button type="button" onclick="loadViewer()">Preview Report</button>
        </div>
        <div style="width: 100%; overflow-x: hidden">
            <div style="float:right;width:100%" id="viewerContainer">
            </div>
        </div>
        <script type="text/javascript" src="jsViewer.min.js"></script>
        <script type="text/javascript">
            let viewer;
            function loadViewer() {
                var customerIdInput = document.getElementById('lblcustomerID');
                var customerId = customerIdInput.value ? (customerIdInput.value) : 0;
                viewer = GrapeCity.ActiveReports.JSViewer.create({
                    element: '#viewerContainer'
                });
                var reportParameters = [{ name: 'Id', values: [customerId] }];
                viewer.openReport('CustomerRdl.rdlx', reportParameters);
            }
        </script>
    </body>
    

    You may also check the attached sample with data for demonstration. Enter Customer Id = 10251 in the form input to generate the report based on it for testing purposes. P.S., add the location of NWind.mdb in the CustomerRdl.rdlx report to run the report.

    Hope this helps!

    Attachment: JSViewerSample.zipNWind.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels