OData

报表支持绑定 Contoso OData End Point 并且可以使用以下链接获取数据

https://demodata.grapecity.com/contoso/odata/v1/DimProductCategories?$expand=DimProductSubcategories($expand=DimProducts)

该报表主要演示了三层嵌套的 JSON 数据的引用,可以通过侧边栏的目录控件来查看主分类和子分类信息。

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReportsJS sample</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> <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-designer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-pdf.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-xlsx.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/ar-js-locales.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/designer/zh-locale.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" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-designer.css" /> <style> #root { height: 100vh; } #viewer-host, #designer-host { height: 100%; } #designer-host { display: none; } </style> </head> <body onload="load()" style="margin: 0"> <div id="root"> <div id="viewer-host"></div> <div id="designer-host"></div> </div> <script> var currentReport = undefined; var viewerHost = document.getElementById("viewer-host"); var designerHost = document.getElementById("designer-host"); function load() { var viewer = new ActiveReports.Viewer("#viewer-host", { language: "zh", }); var designer = new GC.ActiveReports.ReportDesigner.Designer( "#designer-host", { language: "zh" } ); designer.setActionHandlers({ onRender(report) { currentReport = report.definition; viewer.open(currentReport); viewerHost.style.display = "block"; designerHost.style.display = "none"; // return Promise.resolve(); }, }); var designButton = { key: "$openDesigner", text: "编辑", iconCssClass: "mdi mdi-pencil", enabled: true, action: function (item) { designer.setReport({ definition: currentReport, displayName: "OData", }); viewerHost.style.display = "none"; designerHost.style.display = "block"; }, }; viewer.toolbar.addItem(designButton); viewer.toolbar.updateLayout({ default: [ "$openDesigner", "$split", "$navigation", "$split", "$refresh", "$split", "$history", "$split", "$zoom", "$fullscreen", "$split", "$print", "$split", "$singlepagemode", "$continuousmode", "$galleymode", ], }); fetch("ODataBinding.rdlx-json") .then(function (data) { return data.json(); }) .then(function (report) { currentReport = report; viewer.open(report); }); } </script> </body> </html>