设置预置资源

该示例主要展示了为设计器预置资源,即给用户将可选的选项提供好,客户直接在列表中选择。

  • 可指定可选的数据源和数据集列表
  • 指定图像控件选择的路径
  • 指定子报表加载路径

更多操作步骤参考文档 预定义数据源使用共享数据源

<!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" /> <script src="/activereportsjs/demos/arjs/dist/ie-polyfills.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-designer.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-designer.css" /> <style> #designer-host { margin: 0 auto; width: 100%; height: 550px; } </style> </head> <body> <div id="designer-host"></div> <script src="resources.js"></script> <script> const designer = new GC.ActiveReports.ReportDesigner.Designer( "#designer-host", { language: "zh" } ); designer.setDataSourceTemplates([ { id: "Northwind", title: "Northwind", template: resources.dataSource, canEdit: false, datasets: [ { id: "Categories", title: "Categories", template: resources.categoriesDataSet, canEdit: false, }, { id: "Products", title: "Products", template: resources.productsDataSet, canEdit: false, }, ], }, ]); designer.setResourceProvider({ getImagesList: async () => resources.images, getReportsList: async () => resources.reports, }); designer.setReport({ id: "reports/initial.rdlx-json" }); </script> </body> </html>