このトピックでは、ASP .NET MVC CoreとASP .NET MVCアプリケーションを使用してWebデザイナサンプルの作成手順について説明します。





| Startup.cs |
コードのコピー
|
|---|---|
using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using GrapeCity.ActiveReports.Aspnetcore.Designer; namespace WebDesignerSample { public class Startup { // リソース(レポート、テーマ、画像)の場所 private static readonly DirectoryInfo ResourcesRootDirectory = new DirectoryInfo(".\\resources\\"); public void ConfigureServices(IServiceCollection services) { // Webデザイナのサービス services.AddDesigner(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Webデザイナのミドルウェア app.UseDesigner(config => config.UseFileStore(ResourcesRootDirectory)); // 静的ファイルのミドルウェア app.UseDefaultFiles(); app.UseStaticFiles(); } } } |
|

npm init -y
npm i @grapecity/ar-designer@14.2.1764
これらのファイルやフォルダは、以下のように現在のディレクトリにインストールされます。
[現在のディレクトリ]\node_modules\@grapecity\ar-designer\dist


| index.html |
コードのコピー
|
|---|---|
<!DOCTYPE html> <html> <head> <title>Webデザイナサンプル</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <!-- 仮想ディレクトリなし --> <base href="/"> <!-- デザイナ関連のCSSファイル --> <link rel="stylesheet" href="vendor/css/materialdesignicons.min.css" media="all" type="text/css" /> <link rel="stylesheet" href="vendor/css/bootstrap.min.css" /> <link rel="stylesheet" href="vendor/css/font-awesome.min.css"> <link rel="stylesheet" href="vendor/css/ionicons.min.css"> <link rel="stylesheet" href="vendor/css/fonts-googleapis.css" type="text/css"> <link rel="stylesheet" href="web-designer.css" /> </head> <body class="theme-blue"> <!-- デザイナ関連のjsファイル --> <script src="vendor/js/jquery.min.js"></script> <script src="vendor/js/bootstrap.min.js"></script> <script src="baseServerApi.js"></script> <script src="web-designer.js"></script> <!-- デザイナルートdiv --> <div id="designer-id" style="width: 100%; height: 100%;"></div> <script> // デザイナのオプションを作成する var designerOptions = GrapeCity.ActiveReports.WebDesigner.createDesignerOptions(baseServerApi); // デザイナアプリケーションを描画する GrapeCity.ActiveReports.WebDesigner.renderApplication('designer-id', designerOptions); </script> </body> </html> |
|

| index.html |
コードのコピー
|
|---|---|
designerOptions.reportInfo.id = "MyReport.rdlx"; |
|
|
コードのコピー
|
|
|---|---|
<link rel="stylesheet" href="file-dialog.css" /> <link rel="stylesheet" href="web-designer.css" /> |
|
|
コードのコピー
|
|
|---|---|
<script src="file-dialog.js"></script> <script src="web-designer.js"></script> |
|
|
コードのコピー
|
|
|---|---|
<!-- デザイナルートdiv --> < div id="designer-id" style="width: 100%; height: 100%;"></div> <!-- 名前を付けて保存ダイアログルートdiv --> < div id="save-as-dialog-id" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; z-index: 9999;"></div> |
|
|
コードのコピー
|
|
|---|---|
<script>
var showElement = function (id) {
if (!id) return;
($('#' + id)).css('display', 'block');
};
var hideElement = function (id) {
if (!id) return;
($('#' + id)).css('display', 'none');
};
var designerId = 'designer-id';
var saveAsDialogId = 'save-as-dialog-id';
function onSaveAs(options) {
showElement(saveAsDialogId);
// 名前を付けて保存ダイアログを描画する
fileDialog.createSaveReportAsDialog(saveAsDialogId, {
locale: options.locale,
api: {
getReportsList: function () {
return baseServerApi.getReportsList()
.then(function (reportsList) {
return reportsList.map(function (reportInfo) {
return { path: reportInfo.Name };
});
});
},
saveReport: function (saveOptions) {
return baseServerApi.saveNewReport({
name: saveOptions.path,
content: options.reportInfo.content,
}).then(function (saveResult) {
return { id: saveResult.Id };
});
},
},
reportInfo: {
path: options.reportInfo.name,
},
onSuccess: function (saveResult) {
hideElement(saveAsDialogId);
options.onSuccess({ id: saveResult.id, name: saveResult.path });
},
onClose: function () {
hideElement(saveAsDialogId);
},
});
};
// デザイナのオプションを作成する
var designerOptions = GrapeCity.ActiveReports.WebDesigner.createDesignerOptions(baseServerApi);
// 名前を付けて保存ボタンの表示を有効にする
designerOptions.saveAsButton.visible = true;
// 名前を付けて保存時の動作を指定する
designerOptions.onSaveAs = onSaveAs;
// デザイナアプリケーションを描画する
GrapeCity.ActiveReports.WebDesigner.renderApplication(designerId, designerOptions);
</script>
|
|
[名前を付けて保存]ダイアログを使用できるデザイナが作成されます。このようなデザイナは、新しいデータセットを追加せずに既存のレポートを編集するために使用できます。
新しいレポートを作成する、データセットを追加する、およびデザイナからレポートをプレビューするには、「プラグインAPIの使用」を参照してください。
以下の手順は、ASP .NET MVC アプリケーションを使用してActiveReports HTML5 Webデザイナサンプルを作成する方法について紹介します。










以下のように、Startup.csの内容を変更します。
|
コードのコピー
|
|
|---|---|
using System; using System.IO; using System.Linq; using System.Web; using GrapeCity.ActiveReports.Aspnet.Designer; using Owin; using Microsoft.Owin; using Microsoft.Owin.StaticFiles; using Microsoft.Owin.FileSystems; using System.Web.Mvc; using System.Web.Routing; [assembly: OwinStartup(typeof(AspNetDesignerSample.Startup))] namespace AspNetDesignerSample { public class Startup { // リソース(レポート、テーマ、画像)の場所 private static readonly DirectoryInfo ResourcesRootDirectory = new DirectoryInfo(String.Format("{0}.\\resources\\", HttpRuntime.AppDomainAppPath)); public void Configuration(IAppBuilder app) { // Webデザイナのミドルウェア app.UseDesigner(config => config.UseFileStore(ResourcesRootDirectory)); // 静的ファイルのミドルウェア var fileSystem = new PhysicalFileSystem(String.Format("{0}.\\wwwroot\\", HttpRuntime.AppDomainAppPath)); app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new[] { "indexer.html" }, FileSystem = fileSystem }); app.UseStaticFiles(new StaticFileOptions { FileSystem = fileSystem }); } } } |
|

npm i @grapecity/ar-designer@14.2.1764
..\node_modules\@grapecity\ar-designer\dist



追加されたindex.htmlの内容を以下のように変更します。
|
コードのコピー
|
|
|---|---|
<!DOCTYPE html>
<html>
<head>
<title>Webデザイナサンプル</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- 仮想ディレクトリなし -->
<base href="/" >
<!-- デザイナ関連のCSSファイル -->
<link rel="stylesheet" href="wwwroot/vendor/css/materialdesignicons.min.css" media="all" type="text/css" />
<link rel="stylesheet" href="wwwroot/vendor/css/bootstrap.min.css" />
<link rel="stylesheet" href="wwwroot/vendor/css/font-awesome.min.css">
<link rel="stylesheet" href="wwwroot/vendor/css/ionicons.min.css">
<link rel="stylesheet" href="wwwroot/vendor/css/fonts-googleapis.css" type="text/css">
<link rel="stylesheet" href="wwwroot/web-designer.css" />
</head>
<body class="theme-blue">
<!-- デザイナ関連のjsファイル -->
<script src="wwwroot/vendor/js/jquery.min.js"></script>
<script src="wwwroot/vendor/js/bootstrap.min.js"></script>
<script src="wwwroot/baseServerApi.js"></script>
<script src="wwwroot/web-designer.js"></script>
<!-- デザイナルートdiv -->
<div id="designer-id" style="width: 100%; height: 100%;"></div>
<script>
// デザイナのオプションを作成する
var designerOptions = GrapeCity.ActiveReports.WebDesigner.createDesignerOptions(baseServerApi);
// デザイナアプリケーションを描画する
GrapeCity.ActiveReports.WebDesigner.renderApplication('designer-id', designerOptions);
</script>
</body>
</html>
|
|