【问题标题】:How to use DevExpress report designer and report viewer in Angular 10如何在 Angular 10 中使用 DevExpress 报表设计器和报表查看器
【发布时间】:2020-10-27 12:36:27
【问题描述】:

我在前端使用 Angular 10,在后端使用带有存储库模式的 .net 核心 webAPI。我正在尝试使用 DevExpress(v20.1) 报告。但我无法弄清楚如何制作它。我正在搜索它一个星期,但没有结果。 This page 和 this page 解释了它。但是我不知道如何配置这部分代码;

public class ReportDesignerController : Controller {
//...
 public ActionResult GetReportDesignerModel(string reportUrl) {
     string modelJsonScript =
         new ReportDesignerClientSideModelGenerator(HttpContext.RequestServices)
         .GetJsonModelScript(
             reportUrl,                 
             GetAvailableDataSources(), //this metod implemented 
             "DXXRD",   
             "DXXRDV",
             "DXXQB"      
         );
     return Content(modelJsonScript, "application/json");
 }

}

谁能告诉我如何正确配置“DXXRD”、“DXXRDV”、“DXXRDV”。我没有使用 mvc,所以当我用这个替换代码时;

new ReportDesignerClientSideModelGenerator()
         .GetJsonModelScript(
             reportUrl,                 
             GetAvailableDataSources(), 
             "ReportDesigner/Invoke",    
             "WebDocumentViewer/Invoke", 
             "QueryBuilder/Invoke"       .
         );

我必须使用 MVC 才能调用这些控制器和视图。但我没有使用mvc。在我现在的位置上,我开始认为如果没有 MVC,我将无法实现这一目标。所以;

  • 是否可以在像我这样的项目中使用 DevExpress 报告?
  • 如果是怎么办?

【问题讨论】:

    标签: c# angular report devexpress asp.net-core-webapi


    【解决方案1】:

    DevExpress 报告组件使用 ASP.NET MVC Core 控制器使用预定义的路由处理来自 Report DesignerDocument ViewerQuery Builder 的请求:

    因此,必须在您的应用中注册 MVC 中间件和 ASP.NET Core MVC 报告控制器。您可以通过在应用程序启动时添加以下代码来继续:

        using DevExpress.AspNetCore;
        using DevExpress.AspNetCore.Reporting;
        //...
        
        public class Startup {
        //...
           public void ConfigureServices(IServiceCollection services) {
             // Register reporting services in an application's dependency injection container.
              services.AddDevExpressControls();
              // Use the AddMvcCore (or AddMvc) method to add MVC services.
               services.AddMvcCore(); 
         }
        
         public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
               // ...
               app.UseStaticFiles();
               // Initialize reporting services.
               app.UseDevExpressControls();
                // ...
          }
        }
    
    

    您可以在文档中找到更多信息:

    【讨论】:

      猜你喜欢
      • 2014-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多