How do I set default width for StiMobileViewer

Stimulsoft Reports.WEB discussion
Post Reply
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

How do I set default width for StiMobileViewer

Post by jay@bplogix.com »

Interactively, I can set the Zoom to Page Width. How can I in C# set this before the report opens? For example, using StiWebViewerFx you can set the StiWebViewerFxOptions.Toolbar.Zoom property.

Also, is there way to have it auto-resize to the window width when the browser window is resized (similar to how StiWebViewerFx works)?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: How do I set default width for StiMobileViewer

Post by Vladimir »

Hello,

Please try to use the following code:

Code: Select all

        <cc2:StiMobileViewer ID="StiMobileViewer1" runat="server" ShowDesignButton="false" FullScreen="true" />
        <script type="text/javascript">window.onload = function () { jsStiMobileViewer1.actionEvent("ZoomPageWidth"); }</script>
Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: How do I set default width for StiMobileViewer

Post by jay@bplogix.com »

Thanks.

I was also trying to set the Zoom to Page Width when the browser window is resized by using the window.onresize event. This works for the Flash viewer, but the onresize event is never called with the HTML 5 viewer. Is there a sample to show how to do this?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How do I set default width for StiMobileViewer

Post by HighAley »

Hello.

Please, try to use next code:

Code: Select all

window.onload = function () { jsStiMobileViewer1.actionEvent("ZoomPageWidth"); }
        
var resizeTimer;
window.onresize = function () {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(function () { jsStiMobileViewer1.actionEvent("ZoomPageWidth"); }, 300);
}
It resizes the report after the browser is resized.

If you also need to resize the viewer, you should set next property.

Code: Select all

FullScreen="true"
Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: How do I set default width for StiMobileViewer

Post by jay@bplogix.com »

Calling the JavaScript actionEvent("ZoomPageWidth") calls the Page_Load again after the report is completely loaded, which re-loads all of the data from the SQL source, which causes the report to take longer to display (it basically runs the report twice on the first load). Is there a way to set the default width prior to the report rendering?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How do I set default width for StiMobileViewer

Post by HighAley »

Hello.

To avoid this you should add if statement in Page_Load.

Code: Select all

protected void Page_Load(object sender, EventArgs e)
    {   
        if (Page != null && !Page.IsPostBack)
        {
            StiReport report = new StiReport();
            report.Load(appDirectory + "\\Report.mrt");
            
            DataSet data = new DataSet();
            data.ReadXmlSchema(appDirectory + "\\Data\\Demo.xsd");
            data.ReadXml(appDirectory + "\\Data\\Demo.xml");

            report.RegData(data);

            StiMobileViewer1.Report = report;
        }
    }
jay@bplogix.com wrote:Is there a way to set the default width prior to the report rendering?
It's impossible to get size of the browser window on server side. So this option could be set on client-side. After this the report with necessary size is requested from server.

Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: How do I set default width for StiMobileViewer

Post by jay@bplogix.com »

"To avoid this you should add if statement in Page_Load"

When I display my report, it might actually be from a postback. So I cant simply check the Page.IsPostBack flag. The first time the report is actually viewed is from my postback.

The flash viewer does a lot of postbacks, but they add things to the URL (stimulreport_btnimage, sr_print, stimulsoft_viewerfx, stimulsoft_guid) that I look for and skip this logic in those cases. But with the StiMobileViewer it seems that it posts back with no additional data on the URL for me to know to skip loading data.

How else can I determine if the postback is just an internal reporting postback rather than one that I should load my SQL data?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How do I set default width for StiMobileViewer

Post by HighAley »

Hello.

Please, try to check postback from Mobile Viewer this way:

Code: Select all

if (Page.Request.Params["__CALLBACKPARAM"] != null && Page.Request.Params["__CALLBACKPARAM"].IndexOf("cacheReportGuid") > 0)
{ 
        
}
Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: How do I set default width for StiMobileViewer

Post by jay@bplogix.com »

That works great, thanks.

What about with the StiWebViewer ... does that use any caching for page forward/next/zoom? Or do we need to re-load all the data for these events using that viewer?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How do I set default width for StiMobileViewer

Post by HighAley »

Hello.

Yes, it uses server-side cache.
The report is rendered on server and stored in cache.
In StiWebViewer you see the report exported to HTML. When you go to the next page, this page is taken from cache, is exported to HTML and is shown in Viewer.

Thank you.
Post Reply