问题描述
我在前端使用Angular 10,在后端使用存储库模式的.net核心webAPI。我正在尝试使用DevExpress(v20.1)报告。但是我不知道该怎么做。我正在烧一个星期,但没有结果。 This页和this页对此进行了说明。但我不知道如何配置这部分代码;
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,"ReportDesigner/Invoke","WebDocumentViewer/Invoke","QueryBuilder/Invoke" .
);
我必须使用MVC才能调用这些控制器和视图。但是我没有使用mvc。从现在开始,我开始认为如果没有MVC,我将无法实现这一目标。所以;
- 是否可以在像我的项目这样的项目中使用DevExpress报表?
- 如果是,怎么办?
解决方法
DevExpress报表组件使用ASP.NET MVC Core控制器通过预定义的路由来处理来自Report Designer,Document Viewer和Query 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();
// ...
}
}
您可以在文档中找到更多信息: