[{"id":"14d2df97-0676-420c-964d-13426eef1a61","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"12657671-6e6c-4608-ae6d-388d545858df","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"6ea4540d-1449-4cda-9476-7aea94fe92e4","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"8afa6dea-e859-46ff-9492-bbcfb9be02e6","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"3342d713-adf6-4d3d-927a-c18269454a2f","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"c4528dd2-d051-44fc-aaed-03fc5898b4e9","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"55dfa43c-32fc-40cb-ace2-6289ee64a56c","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"12e3d04c-a41d-44e3-bb5e-844d20706258","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"d743e457-9ea8-4a4c-8693-98b2914a8687","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"c29576aa-6a99-4d96-85f3-0c18fd4cc690","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"64db515c-5722-4cee-a216-402fe61de0ea","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"9a15e1ef-b289-40c7-8b67-86751cd27633","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"8bdc33fd-1f2a-418b-a930-a31f5bc2cdf8","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"46f440e9-0dc3-419d-9628-d1828c65a287","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"5daa39c5-b191-4c5e-9390-e1e99b01f262","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"1fac4778-f96c-4ebd-869f-721dbb56fdf9","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"c63ad869-9774-40a4-a810-e8822e878cdb","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"e20c310b-707e-4184-a34e-44efc18718e8","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"3f38aa91-b42d-4dcf-afc6-e168fa3643b1","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"0c39c17a-54f4-43ee-96e8-9e712712e73f","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"eb3f4f7d-3203-4434-8f6e-a8d0de4be95c","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"3d3d8e01-9dc6-4942-96ec-245e80322b4f","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"bd4e1539-7ff3-416e-9616-2ebd4dcf975a","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"c843ccac-1afb-4bf8-af53-ce2c372bd4d0","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"63c1f639-7fdc-4916-b88b-5feec0932d38","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"2dd357b0-2e3e-4bc7-a76a-6ffa143b539f","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"fefd2537-65ac-4ccc-ad4e-d7de9b97d390","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"6f1b7d46-2a6b-4f55-8e8d-976f91c0c538","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"31a616d1-2afb-4315-ac01-1679a605ee73","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"38f9879b-ac55-47be-aa85-cd6719c685cc","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"ceb327c0-7c44-431e-bcc2-edb578760b97","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"7c4e0318-8d49-4df0-91b8-f63ab944a9b1","tags":[{"product":null,"links":null,"id":"92283933-94f9-4e9a-8d93-15ba4ec8b3ec","name":"upd","color":"#7e678a","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]},{"id":"812e0f7f-9fd2-47bb-9ffa-a98b7af0565f","tags":[{"product":null,"links":null,"id":"e1d31134-0bda-4c05-bee0-b1f21f82940b","name":"new","color":"#00A273","productId":"77f3d9a0-2c87-4130-b77a-b94ccf13e3cb"}]}]
        
(Showing Draft Content)

レポートのプレビュー

Webデザイナコンポーネントでは、レポートをプレビューする機能が用意されていません。そのためホストアプリケーションのコードで設定する必要があります。このトピックでは、いくつかの一般的なシナリオについて説明しています。

[プレビュー]ボタンを有効にする

Webデザイナコンポーネントでは、ツールバーに[プレビュー]ボタンが含まれています。ただし、これは既定で無効になっています。このボタンを有効にするには、コードでWebデザイナコンポーネントのインスタンスに対してonRenderアクションハンドラを設定する必要があります。詳細については、アクションハンドラを参照してください。ユーザーが[プレビュー]ボタンを押すと、デザイナはonRenderハンドラを呼び出します。デザイナは、表示されているレポートのID、表示名、およびレポート定義などを含む情報を最初の引数に渡します。onRenderハンドラは、ActiveReportJSビューワのインスタンスにレポート定義をロードするか、サポートされている形式でレポートをエクスポートします。詳細については、次のセクションを参照してください。

以下は、ReactアプリケーションでonRenderハンドラを使用して、現在表示されているレポートをActiveReportsJSビューワに表示するサンプルです。

import { Designer as ReportDesigner } from "@grapecity/activereports/reportdesigner";
import React from "react";
import {
  RDLReportDefinition,
  Viewer as ReportViewer,
} from "@grapecity/activereports-react";
import "@grapecity/activereports/styles/ar-js-ui.css";
import "@grapecity/activereports/styles/ar-js-viewer.css";
import "@grapecity/activereports/styles/ar-js-designer.css";

export const DesignerHost: React.FC = () => {
  const designerRef = React.useRef<ReportDesigner | undefined>();
  const viewerRef = React.useRef<ReportViewer | null>(null);

  React.useEffect(() => {
    designerRef.current = new ReportDesigner("#designer-host");
    designerRef.current.setActionHandlers({
      onRender(report) {
        viewerRef.current?.Viewer.open(
          report.definition as RDLReportDefinition
        );
        return Promise.resolve();
      },
    });
  }, []);

  return (
    <div id="app-host">
      <div id="designer-host"></div>
      <div id="viewer-host">
        <ReportViewer ref={viewerRef} />
      </div>
    </div>
  );
};

React、Angular、Vue、およびJavaScriptアプリケーションの完全な実装例については、デモを参照してください。

UIイベントに応じてレポートをプレビューする

ActiveReportJSデザイナのインスタンスのgetReportメソッドを使用して、表示されているレポートの情報を取得できます。このメソッドを使用して、サポートされている形式でレポートをエクスポートするカスタムの[プレビュー]ボタンを追加します。以下は、Reactアプリケーションでこの方法を実装するサンプルです。

import { Designer as ReportDesigner } from "@grapecity/activereports/reportdesigner";
import React from "react";
import "@grapecity/activereports/styles/ar-js-ui.css";
import "@grapecity/activereports/styles/ar-js-viewer.css";
import "@grapecity/activereports/styles/ar-js-designer.css";
import { Core, PdfExport } from "@grapecity/activereports";
import "@grapecity/activereports-localization";

export const DesignerHost: React.FC = () => {
  const designerRef = React.useRef<ReportDesigner | undefined>();

  const onPdfPreview = async () => {
    const reportInfo = await designerRef.current?.getReport();
    const report = new Core.PageReport();
    await report.load(reportInfo?.definition);
    const doc = await report.run();
    const result = await PdfExport.exportDocument(doc);
    result.download("exportedreport.pdf");
  };

  React.useEffect(() => {
    designerRef.current = new ReportDesigner("#designer-host", );
  }, []);

  return (
    <div id="app-host">
      <button onClick={() => onPdfPreview()} id="btn-get-pdf">
        Get PDF Report
      </button>
      <div id="designer-host"></div>
    </div>
  );
};

React、Angular、Vue、およびJavaScriptアプリケーションの完全な実装例については、デモを参照してください。

関連トピック