How to: Access the Report Parameters Object in Calculated Fields Expressions How to: Access report parameters in the calculation of the object field expression

This topic describes how you can access data of a report parameters object (inherited from ReportParametersObjectBase and specified using IReportDataV2.ParametersObjectType) in calculated field expressions.

This topic describes how to access the data object in the report parameters calculated field expressions (inherited from the report parameter object library and use IReportDataV2. Parameter specifies the object type).

 

Note Note
The approach described in this topic is not supported by the Mobile platform.
Mobile platform approach described in this topic is not supported.

 

Override the Parameters Object's ToString method.

ToString method parameter object covering.

public class DemoParameters : ReportParametersObjectBase {
    // ...
    public override string ToString() {
        return City;
    }
}

 

As a result, you can refer to the ToString result with the "[Parameters.XafReportParametersObject]" expression, e.g.:

Therefore, you can use the "[parameter .XafReport parameter object]" expression refers ToString results, such as:

Concat([Full Name],' from ', [Parameters.XafReportParametersObject])

 

Alternatively, you can create a report script, handle the GetValue event of a certain field and then access a parameter value as demonstrated in the How to: Access the Report Parameters Object in Report Scripts topic.

Alternatively, you can create a report script, processing GetValue event-specific field, and then access parameter values, such as "How to: access a report in the report script parameter object" shown topic.

private void calculatedFieldCity_GetValue(object sender, DevExpress.XtraReports.UI.GetValueEventArgs e) {
    DevExpress.XtraReports.Parameters.Parameter param =
            (DevExpress.XtraReports.Parameters.Parameter)
                ((DevExpress.XtraReports.UI.XtraReport)e.Report).Parameters["XafReportParametersObject"];
    if (param != null) {
        ReportV2Demo.Module.BusinessObjects.Contact contact = 
        (ReportV2Demo.Module.BusinessObjects.Contact)e.Row;
        ReportV2Demo.Module.Reports.DemoParameters xafParameter =
            (ReportV2Demo.Module.Reports.DemoParameters)param.Value;
        e.Value = contact.FullName + " from " + xafParameter.City;
    }
}

 

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Access-the-Report-Parameters-Object-in-Calculated-Fields-Expressions.html