设置预置资源

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

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

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

<template> <div id="designer-host"></div> </template> <script> import Vue from "vue"; import { Designer as ReportDesigner } from "@grapecity/activereports/reportdesigner"; import '@grapecity/activereports-localization-zh'; import { dataSource, categoriesDataSet, productsDataSet, images, reports, } from "./resources.js"; const app = { name: "App", mounted: function () { const designer = new ReportDesigner("#designer-host",{ language: "zh" }); designer.setDataSourceTemplates([ { id: "Northwind", title: "Northwind", template: dataSource, canEdit: false, datasets: [ { id: "Categories", title: "Categories", template: categoriesDataSet, canEdit: false, }, { id: "Products", title: "Products", template: productsDataSet, canEdit: false, }, ], }, ]); designer.setResourceProvider({ getImagesList: async () => images, getReportsList: async () => reports, }); designer.setReport({ id: "reports/initial.rdlx-json" }); }, }; new Vue({ render: (h) => h(app), }).$mount("#app"); </script> <style> @import url("/activereportsjs/demos/arjs/styles/ar-js-ui.css"); @import url("/activereportsjs/demos/arjs/styles/ar-js-designer.css"); #designer-host { width: 100%; height: 550px; } </style>
<!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" /> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import("./app.vue"); </script> </head> <body style="margin: 0"> <div id="app"></div> </body> </html>
(function (global) { System.config({ transpiler: "plugin-babel", babelOptions: { es2015: true, }, meta: { "*.css": { loader: "css" }, "*.vue": { loader: "vue-loader" }, }, paths: { // paths serve as alias "npm:": "node_modules/", }, // map tells the System loader where to look for things map: { jszip: "npm:jszip/dist/jszip.js", css: "npm:systemjs-plugin-css/css.js", vue: "npm:vue/dist/vue.min.js", "vue-demi": "npm:vue-demi/lib/index.cjs.js", "@vue/composition-api": "npm:@vue/composition-api/dist/vue-composition-api.js", "vue-loader": "npm:systemjs-vue-browser/index.js", "plugin-babel": "npm:systemjs-plugin-babel/plugin-babel.js", "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", "@grapecity/activereports/pdfexport": "npm:@grapecity/activereports/dist/ar-js-pdf.js", "@grapecity/activereports/tabulardataexport": "npm:@grapecity/activereports/dist/ar-js-tabular-data.js", "@grapecity/activereports/htmlexport": "npm:@grapecity/activereports/dist/ar-js-html.js", "@grapecity/activereports/xlsxexport": "npm:@grapecity/activereports/dist/ar-js-xlsx.js", "@grapecity/activereports-vue": "npm:@grapecity/activereports-vue/lib/index.js", "@grapecity/activereports/reportviewer": "npm:@grapecity/activereports/dist/ar-js-viewer.js", "@grapecity/activereports/viewer": "npm:@grapecity/activereports/dist/ar-js-viewer.js", "@grapecity/activereports/reportdesigner": "npm:@grapecity/activereports/dist/ar-js-designer.js", "@grapecity/activereports/core": "npm:@grapecity/activereports/dist/ar-js-core.js", "@grapecity/activereports/styles": "npm:@grapecity/activereports/styles", "@grapecity/activereports-localization-ja": "npm:@grapecity/activereports-localization/dist/designer/ja-locale.js", "@grapecity/activereports-localization-zh": "npm:@grapecity/activereports-localization/dist/designer/zh-locale.js", "@grapecity/ar-js-pagereport": "npm:@grapecity/activereports/dist/ar-js-core.js", }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: "js", }, node_modules: { defaultExtension: "js", }, }, }); })(this);