Page 1 of 1

Setup Designer with Data

Posted: Wed Mar 18, 2015 7:45 pm
by ksimmons
I have an MVC project that we would like to add reporting to. I want to allow users to create new mrt files within the designer and just pass the data source to it. How can I open the designer without pre-defining a report? The code below opens the designer but does not have the data source populated and just keeps throwing "Error: Internal Server Error" messages:

View:

Code: Select all

@Html.Stimulsoft().StiMvcMobileDesigner(
    "StimulsoftDesigner1",
    new StiMvcMobileDesignerOptions
    {
        
        ActionGetReportTemplate = "GetReportTemplate",
        ActionGetReportSnapshot = "GetReportSnapshot",
        ActionSaveReportTemplate = "SaveReportTemplate"
    })
Controller:

Code: Select all

        public ActionResult GetReportTemplate()
        {
            StiReport report = new StiReport();

            DataTable dt = (DataTable)Session["ReportSource"];
            report.RegData(dt);

            return StiMvcMobileDesigner.GetReportTemplateResult(HttpContext, report);
        }

        public ActionResult GetReportSnapshot()
        {
            StiReport report = StiMvcMobileDesigner.GetReportObject(HttpContext);

            // Register data, if necessary
            DataTable dt = (DataTable)Session["ReportSource"];
            report.RegData(dt);

            // Return the report snapshot result to the client
            return StiMvcMobileDesigner.GetReportSnapshotResult(HttpContext, report);
        }

        public ActionResult SaveReportTemplate()
        {
            StiReport report = StiMvcMobileDesigner.GetReportObject(HttpContext);
            report.Save(@"D:\" + report.ReportName + ".mrt");

            return StiMvcMobileDesigner.SaveReportTemplateResult(HttpContext);
        }

Re: Setup Designer with Data

Posted: Thu Mar 19, 2015 11:24 am
by HighAley
Hello.

Please, call next method after registering data:

Code: Select all

report.Dictionary.Synchronize();
As about error, when do you get Internal Server Error? Could you send us a sample project?

Thank you.

Re: Setup Designer with Data

Posted: Thu Mar 19, 2015 5:31 pm
by ksimmons
Attached is the sample project. The call to Synchronize works, but it throws an error whenever I try to add something to the report (i.e. a data band, report title, etc).

Re: Setup Designer with Data

Posted: Fri Mar 20, 2015 12:52 pm
by HighAley
Hello.

You missed one necessary action. You should add it to your project.

Code: Select all

        public ActionResult DesignerEvent()
        {
            return StiMvcMobileDesigner.DesignerEventResult(HttpContext);
        }
Thank you.

Re: Setup Designer with Data

Posted: Fri Mar 20, 2015 9:40 pm
by ksimmons
Perfect! Thanks! I totally missed the need for it in the documentation.

Re: Setup Designer with Data

Posted: Mon Mar 23, 2015 4:20 am
by HighAley
Hello.

We will create a greater emphasis on this in our documentation.

Thank you.