방법 : 목록에보고하는 방법에 사용자 지정 열을 추가 : 추가 사용자 정의 열을 보고서 목록에

이 항목에서는 저장하는 데 사용되는 영속 클래스 사용자 지정하는 방법에 대해 설명 보고서 보고서 개체와 추가 정보를 연결할 수 있습니다. 예를 들어, 추가 분류 특성은에서 추가 열 발생합니다 보고서 목록보기 및 최종 사용자는 범주별로 그룹화, 정렬하거나 필터링 할 수 있습니다.

이 항목에서는 추가 정보와 객체와 관련된 보고서를 위해 상점 지속적인 보고서 클래스를 지정하는 방법에 대해 설명합니다. 예를 들어, 보고서 목록보기에서 다른 열이 나타납니다 발생합니다 "클래스"속성을 추가, 최종 사용자 정렬 또는 필터 카테고리별로 분류 할 수있을 것입니다.

 

윈폼 :

ReportsV2_WizParamsRuntime

ASP.NET :

ReportsV2_WizParamsRuntime_Web

이 주제에서는 사용자가 사용하는 XAF 응용 프로그램이 있다고 가정 보고서 V2 모듈을 , 당신은 하나 이상의 보고서를 (참조 만든 보고서 V2 모듈 개요 ).

이 항목에서는 사용자가 XAF 애플리케이션 V2 모듈을 사용하여 보고서가 있다고 가정하고, 하나 개 이상의 보고서 (보고서 개요 V2 모듈을 참조)를 만듭니다.

 

Note주의
Mobile applications do not support the Report Wizard, so the approach described in this topic cannot be implemented in the Mobile platform.
移动应用程序不支持报表向导,因此本主题中描述的方法无法在移动平台中实现。
 
Tip 提示
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T154234
完整的示例项目可在 DevExpress 代码示例数据库中找到,http://www.devexpress.com/example=T154234

.

Inherit ReportDataV2

继承报表数据V2

Entity Framework 实体框架

If you use the Entity Framework, create the MyReportDataV2 entity derived from DevExpress.Persistent.BaseImpl.EF.ReportDataV2. Then, add your custom entity to the DbContext.

如果使用实体框架,请创建从 DevExpress 派生的 MyReportDataV2 实体。然后,将自定义实体添加到 DbContext。

public class MyReportDataV2 : DevExpress.Persistent.BaseImpl.EF.ReportDataV2 {
    public string Category { get; set; }
}

public class MySolutionDbContext : DbContext {
    // ...
    public DbSet<ReportDataV2> ReportDataV2 { get; set; }
    public DbSet<MyReportDataV2> MyReportDataV2 { get; set; }
}

 

XPO

If you use XPO, create the MyReportDataV2 persistent class derived from DevExpress.Persistent.BaseImpl.ReportDataV2.

如果使用 XPO,请创建从 DevExpress 派生的 MyReportDataV2 持久类。

public class MyReportDataV2 : DevExpress.Persistent.BaseImpl.ReportDataV2 {
    public MyReportDataV2(Session session) : base(session) { }
    private string category;
    public string Category {
        get { return category; }
        set { SetPropertyValue(nameof(Category), ref category, value); }
     }
}

 

Specify ReportsModuleV2.ReportDataType

指定报表模块V2.报表数据类型

In the Application Designer, set the ReportsModuleV2.ReportDataType property value to MyReportDataV2.

在应用程序设计器中,将报表模块V2.报表数据类型属性值设置为 MyReportDataV2。

ReportsV2_ReportDataType

Repeat this step for both the WinApplication.cs (WinApplication.vb) and WebApplication.cs (WebApplication.vb) files.

对WinApplication.cs (WinApplication.vb) 和WebApplication.cs (WebApplication.vb) 文件重复此步骤。

Add the New Property to the Report Wizard

将新属性添加到报表向导

Note 注意
You can omit this section if you do not want the additional property to be initialized by a user. Instead, you can customize the ReportsStorage class to update the property value in code.
如果不希望用户初始化其他属性,则可以省略此部分。相反,您可以自定义报表存储类以更新代码中的属性值。

 

To make the newly introduced property visible in the Report Wizard, do the following.

  • In the platform-agnostic module project, inherit from the NewXafReportWizardParameters class and declare the Category string property.

要使新引入的属性在"报表向导"中可见,可以执行以下操作。

  • 在与平台无关的模块项目中,从 NewXafReportWizard 参数类继承并声明类别字符串属性。
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.ReportsV2;
using DevExpress.ExpressApp.ReportsV2.Win;
using DevExpress.XtraReports.UI;
// ...
[DomainComponent]
public class CustomReportWizardParameters : NewReportWizardParameters {
    public CustomReportWizardParameters(XtraReport report, Type reportDataType) : 
        base(report, reportDataType) { }
    public string Category { get; set; }
    public override void AssignData(IReportDataV2Writable reportData) {
        base.AssignData(reportData);
        if (reportData is MyReportDataV2) {
            ((MyReportDataV2)reportData).Category = Category;
        }
    }
}

 

  • In the WinForms module project, implement a View Controller. Override the OnActivated method, access the standard WinReportServiceController and subscribe to its WinReportServiceController.NewXafReportWizardShowing event. In the event handler, pass an instance of the CustomReportWizardParameters class to the Report Wizard.

  • 在 WinForms 模块项目中,实现视图控制器。覆盖 On 激活方法,访问标准的 WinReport 服务控制器并订阅其 WinReport 服务控制器。在事件处理程序中,将自定义报告向导参数类的实例传递给报表向导。

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.ReportsV2.Win;
    // ...
    public class ReportWizardModifyController : ViewController {
        WinReportServiceController reportServiceController;
        public ReportWizardModifyController() { }
        protected override void OnActivated() {
            base.OnActivated();
            reportServiceController = Frame.GetController<WinReportServiceController>();
            if (reportServiceController != null) {
                reportServiceController.NewXafReportWizardShowing +=
                    reportServiceController_NewXafReportWizardShowing;
            }
        }
        protected override void OnDeactivated() {
            reportServiceController.NewXafReportWizardShowing -=
                reportServiceController_NewXafReportWizardShowing;
            reportServiceController = null;
            base.OnDeactivated();
        }
        void reportServiceController_NewXafReportWizardShowing(object sender,
            NewXafReportWizardShowingEventArgs e) {
            if (!e.ReportDataType.Equals(typeof(MyReportDataV2))) return;
            CustomReportWizardParameters newReportParamsObject = new
                CustomReportWizardParameters(e.WizardParameters.Report, e.WizardParameters.ReportDataType);
            newReportParamsObject.Category = "Default";
            e.WizardParameters = newReportParamsObject;
        }
    }

     

  • In the ASP.NET module project, implement one more View Controller. Analogously, override the OnActivated method, access the standard WebReportServiceController and subscribe to its WebReportServiceController.NewReportWizardShowing event. In the event handler, pass an instance of the CustomReportWizardParameters class to the Report Wizard.

  • 在ASP.NET模块项目中,实现一个视图控制器。类似地,重写 OnActivated 方法,访问标准 Web 报表服务控制器并订阅其 Web 报表服务控制器。NewReportWizard 显示事件。在事件处理程序中,将自定义报告向导参数类的实例传递给报表向导。

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.ReportsV2.Web;
    // ...
    public class ReportWizardModifyController : ViewController {
        WebReportServiceController reportServiceController;
        public ReportWizardModifyController() { }
        protected override void OnActivated() {
            base.OnActivated();
            reportServiceController = Frame.GetController<WebReportServiceController>();
            if (reportServiceController != null) {
                reportServiceController.NewReportWizardShowing +=
                    reportServiceController_NewReportWizardShowing;
            }
        }
        protected override void OnDeactivated() {
            reportServiceController.NewReportWizardShowing -=
                reportServiceController_NewReportWizardShowing;
            reportServiceController = null;
            base.OnDeactivated();
        }
        void reportServiceController_NewReportWizardShowing(object sender,
            WebNewReportWizardShowingEventArgs e) {
            if (!e.ReportDataType.Equals(typeof(MyReportDataV2))) return;
            CustomReportWizardParameters newReportParamsObject = new
                CustomReportWizardParameters(e.WizardParameters.Report, e.WizardParameters.ReportDataType);
            newReportParamsObject.Category = "Default";
            e.WizardParameters = newReportParamsObject;
        }
    }

     

The following Detail Views are added to the Application Model after performing the steps above.

  • MyReportData_DetailView
  • CustomReportWizardParameters_DetailView

执行上述步骤后,以下详细信息视图将添加到应用程序模型中。

  • MyReportData_DetailView
  • CustomReportWizardParameters_DetailView

 

To place the new Category item at the desired position, start the Model Editor and adjust these Detail View layouts.

원하는 위치에 새로운 "카테고리"항목을 추가하려면 모델 편집기를 시작하고 다음 레이아웃을 "상세보기"조정합니다.

ReportsV2_WizParams

디테일 뷰의 레이아웃을 사용자 정의하는 방법에 대한 자세한 설명은 참조 항목보기 레이아웃 사용자 지정 도움말 항목을 참조하십시오.

레이아웃보기를 사용자 정의하는 방법에 대한 자세한 내용은보기 프로젝트 레이아웃 사용자 지정 도움말 항목을 참조하십시오.

추천

출처www.cnblogs.com/foreachlife/p/How-to-Add-a-Custom-Column-to-the-Reports-List.html