Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Using RAP to control SubReport NoDataBehaviours

Hello

On the Before print of the Report - I want to check a list of parameters I have passed to the Report - to let me know whether I should allow the sub-report to print or not. (I have multiple sub-reports that represent different categories of the report - and I want the user to be able to select at run time which sub-reports will print.

I am currently trying to do this in the BeforePrint event of the report. The parameters will be Boolean - so I check to see if they are true or not.

procedure ReportBeforePrint;
begin
if (Report.Parameters['Test'] = True) then
srHistory.NoDataBehaviors := [ndBlankPage];
else
srHistory.NoDataBehaviors := [ndBlankReport];
end;


I am getting a RAP Compile error of
Line 4 Expected '(' or '[' but found NoDataBehaviours instead.

I am obviously doing something wrong here - would love some suggestions :)

Bradley


Comments

  • Hi Brad,

    RAP does not support set types. To work around this we have added helper boolean properties for certain sets (ex. TFont.Style). I will add it to our list to add some for NoDataBehaviors.

    Currently you will need to create a pass-thru function to alter the NoDataBehaviors from RAP. Something like the following...

    uses
    ppTypes, raFunc, ppRTTI;

    ...

    TmyAddNoDataFunction = class(TraUtilityFunction)
    public
    class function GetSignature: String; override;
    class function IsFunction: Boolean; override;
    procedure ExecuteFunction(aParams: TraParamList); override;
    end;

    TmyRemoveNoDataFunction = class(TraUtilityFunction)
    public
    class function GetSignature: String; override;
    class function IsFunction: Boolean; override;
    procedure ExecuteFunction(aParams: TraParamList); override;
    end;

    ...

    implementation

    ...

    { TmyAddNoDataFunction }

    procedure TmyAddNoDataFunction.ExecuteFunction(aParams: TraParamList);
    var
    lReport: TppReport;
    liNoDataBehavior: Integer;
    begin

    GetParamValue(0, lReport);
    GetParamValue(1, liNoDataBehavior);

    lReport.NoDataBehaviors := lReport.NoDataBehaviors + [TppNoDataBehaviorType(liNoDataBehavior)];

    end;

    class function TmyAddNoDataFunction.GetSignature: String;
    begin
    Result := 'procedure AddNoDataBehaviors(aReport: TppReport; aNoDataBehaviors: Integer);';

    end;

    class function TmyAddNoDataFunction.IsFunction: Boolean;
    begin
    Result := False;

    end;

    { TmyRemoveNoDataFunction }

    procedure TmyRemoveNoDataFunction.ExecuteFunction(aParams: TraParamList);
    var
    lReport: TppReport;
    liNoDataBehavior: Integer;
    begin

    GetParamValue(0, lReport);
    GetParamValue(1, liNoDataBehavior);

    lReport.NoDataBehaviors := lReport.NoDataBehaviors - [TppNoDataBehaviorType(liNoDataBehavior)];

    end;

    class function TmyRemoveNoDataFunction.GetSignature: String;
    begin
    Result := 'procedure RemoveNoDataBehaviors(aReport: TppReport; aNoDataBehaviors: Integer);';

    end;

    class function TmyRemoveNoDataFunction.IsFunction: Boolean;
    begin
    Result := False;

    end;

    initialization
    raRegisterFunction('AddNoDataBehaviors', TmyAddNoDataFunction);
    raRegisterFunction('RemoveNoDataBehaviors', TmyRemoveNoDataFunction);

    finalization
    raUnRegisterFunction('AddNoDataBehaviors');
    raUnRegisterFunction('RemoveNoDataBehaviors');

    end.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.