뷰어 컴포넌트 - 매개변수 값 설정

보고서 뷰어 API를 사용하면 특정 매개 변수 값을 적용하여 매개 변수화된 보고서를 열 수 있습니다. 이 기능은 사용자 정의 매개 변수 패널을 구현하거나 런타임에 값을 수신하는 숨겨진 매개 변수를 사용하려는 경우에 유용합니다. 아래 샘플은 Angular, React, Vue 및 순수 JavaScript 애플리케이션을 사용한 사용자 정의 매개 변수 패널의 구현을 보여줍니다. 도움말 문서를 방문하여 더 많은 정보를 얻으실 수 있습니다. 코드를 보려면 페이지를 아래로 스크롤하세요.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReportsJS Report Viewer Setting Parameters Values Sample</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous" /> <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css" /> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-viewer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-pdf.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-tabular-data.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/ar-js-locales.js"></script> <script src="$DEMOROOT$/lib/purejs/license.js"></script> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-ui.css" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-viewer.css" /> <style> #viewer-host { margin: 0 auto; width: 100%; height: 500px; } </style> </head> <body> <div class="container-fluid"> <div class="form-group mb-3 mt-3"> <div> <label>Select Product Categories</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-1" checked /> <label class="form-check-label" for="category-1">Beverages</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-2" /> <label class="form-check-label" for="category-2">Condiments</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-3" /> <label class="form-check-label" for="category-3">Confections</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-4" /> <label class="form-check-label" for="category-4">Dairy Products</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-5" /> <label class="form-check-label" for="category-5">Grains/Cereals</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-6" /> <label class="form-check-label" for="category-6">Meat/Poultry</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-7" /> <label class="form-check-label" for="category-7">Produce</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" id="category-8" /> <label class="form-check-label" for="category-8">Seafood</label> </div> <div class="mt-1"> <button type="button" class="btn btn-outline-primary" onclick="setCategories()" id="btnPreview">Preview Report</button> </div> </div> </div> </div> <div id="viewer-host"></div> <script> const viewer = new MESCIUS.ActiveReportsJS.ReportViewer.Viewer("#viewer-host"); viewer.theme="ActiveReports"; viewer.documentLoaded.register(function(){ document.getElementById("btnPreview").removeAttribute("disabled"); }); viewer.reportLoaded.register(function(){ document.getElementById("btnPreview").setAttribute("disabled", true); }); const categoryIds = [1, 2, 3, 4, 5, 6, 7, 8]; const availableCategories = []; function setCategories() { availableCategories.length = 0; categoryIds.forEach(function (categoryId) { const checkBox = document.getElementById("category-" + categoryId); if (checkBox && checkBox.checked) { availableCategories.push(categoryId); } }); viewer.open("reports/multi-value-param.rdlx-json", { ReportParams: [ { Name: "CategoryId", Value: availableCategories, }, ], }); } MESCIUS.ActiveReportsJS.Core.FontStore.registerFonts( "/activereportsjs/demos/resource/fontsConfig.json" ); setCategories(); </script> </body> </html>