Page 1 of 1

How do I set default width for StiMobileViewer

Posted: Tue Jan 19, 2016 6:50 pm
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)?

Re: How do I set default width for StiMobileViewer

Posted: Wed Jan 20, 2016 7:12 am
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.

Re: How do I set default width for StiMobileViewer

Posted: Wed Jan 20, 2016 10:57 pm
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?

Re: How do I set default width for StiMobileViewer

Posted: Thu Jan 21, 2016 10:14 am
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.

Re: How do I set default width for StiMobileViewer

Posted: Thu Jan 21, 2016 7:13 pm
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?

Re: How do I set default width for StiMobileViewer

Posted: Fri Jan 22, 2016 11:56 am
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.

Re: How do I set default width for StiMobileViewer

Posted: Tue Jan 26, 2016 12:36 am
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?

Re: How do I set default width for StiMobileViewer

Posted: Tue Jan 26, 2016 7:59 am
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.

Re: How do I set default width for StiMobileViewer

Posted: Tue Jan 26, 2016 7:10 pm
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?

Re: How do I set default width for StiMobileViewer

Posted: Wed Jan 27, 2016 6:52 am
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.