Page 2 of 2

Change the sql command before preview

Posted: Thu May 17, 2012 10:03 am
by HighAley
Hello.
[quote="marco".correa]We should like that when "report preview" is canceled the user see a message that is not a error.

Actually we are throwing a exception to cancel a report preview.

Code: Select all

            StiOptions.Engine.GlobalEvents.PreviewingReportInDesigner += (s, args) =>
            {   
               // disregard the verification below, this is only a sample to illustrate 
              //  the event that we are using and the exception raised.
                if (1 == 1)
                    throw new Exception("Visualização do relatório cancelada.");
            };
[/quote]
You still didn't write what behaviour of the Designer are you waiting for. Do you want the Designer does back to the Design tab?

If there are any error no message will be shown and users will see a blank report. You could show message using MessageBox.Show() method.

Thank you.

Change the sql command before preview

Posted: Fri May 18, 2012 7:23 am
by marco.correa
Hello,

My doubt is how we can cancel report preview without throw a exception to the user. Today we are treating this behavior with a exception. Is there another way?

Thank you.

Change the sql command before preview

Posted: Fri May 18, 2012 8:41 am
by Alex K.
Hello,

Please send us a sample project which reproduces your issue for analysis.

Thank you.

Change the sql command before preview

Posted: Mon May 21, 2012 10:03 am
by marco.correa
Follows the sample project.

Change the sql command before preview

Posted: Tue May 22, 2012 7:59 am
by HighAley
Hello.

Please, describe filterSettings.Length == 0 condition. Does it constant or could be changed at design time?

If it is unchangeable then you could pass the necessary data to report with RegData or UserDataSource methods and remove preview tab from designer.

In other case you could use next code:

Code: Select all

StiOptions.Engine.GlobalEvents.PreviewingReportInDesigner += (s, args) =>
{
    if (filterSettings.Length == 0)
    {
        StiReport rep = (s as Stimulsoft.Report.Design.StiDesignerControl).Report;
        rep.NeedsCompiling = false;
        rep.IsRendered = true;
        rep.RenderedPages.Clear();
    }
    else
    {
        StiReport rep = (s as Stimulsoft.Report.Design.StiDesignerControl).Report;
        rep.NeedsCompiling = true;
        rep.IsRendered = false;
    }
};
Thank you.

Change the sql command before preview

Posted: Wed May 23, 2012 7:48 am
by marco.correa
Hello,

In our case the filterSetting is changeable.

We added your code but now it's printed a white screen when filterSettings.Length == 0. Is there any way to go back to "Page 1" tab or just no show anything to user ?

Thank you.

Change the sql command before preview

Posted: Wed May 23, 2012 9:37 am
by Alex K.
Hello,

[quote="marco".correa]Is there any way to go back to "Page 1" tab or just no show anything to user ?[/quote]

Unfortunately, it is impossible.

Thank you.