Page 1 of 1

Stimulsoft.Reports.Web.NetCore StiDesigner with Angular

Posted: Sun Apr 05, 2020 9:58 am
by rabbal
Hi there,
I'm using StiDesigner of Stimulsoft.Reports.Web.NetCore package with Angular like your "Web API with Angular" sample for StiViewer in github, but in preview page, some controls have "undefined" text.
The attachment a.PNG is no longer available
//Index.html
<script src="reporting/designer"></script>

//DesignerController

Code: Select all

[Route("reporting/designer")]
public class DesignerController : Controller
{
    [HttpGet]
    public IActionResult Get()
    {
        var requestParams = StiNetCoreDesigner.GetRequestParams(this);
        if (requestParams.Action == StiAction.Undefined)
        {
            var options = new StiNetCoreDesignerOptions
            {
                Theme = StiDesignerTheme.Office2013WhiteBlue,
                Server = {UseCompression = true, PassFormValues = true, UseCacheForResources = true},
            };

            return StiNetCoreDesigner.GetScriptsResult(this, options);
        }

        return StiNetCoreDesigner.ProcessRequestResult(this);
    }

    [HttpPost]
    public IActionResult Post()
    {
        var requestParams = StiNetCoreDesigner.GetRequestParams(this);
        switch (requestParams.Action)
        {
            case StiAction.SaveReport:
                return SaveReport();
            case StiAction.GetReport:
                return LoadReport(requestParams);
            case StiAction.PreviewReport:
                return PreviewReport(requestParams);
            default:
                return StiNetCoreDesigner.ProcessRequestResult(this);
        }
    }

    private IActionResult LoadReport(StiRequestParams requestParams)
    {
        //var reportName = requestParams.FormValues["__ReportName"];
        var report = new StiReport();

        report.Load(StiNetCoreHelper.MapPath(this, "Reports/TwoSimpleListsRed.mrt"));

        return StiNetCoreDesigner.GetReportResult(this, report);
    }

    private IActionResult PreviewReport(StiRequestParams requestParams)
    {
        var report = StiNetCoreDesigner.GetActionReportObject(this);

        return StiNetCoreDesigner.PreviewReportResult(this, report);
    }

    public IActionResult SaveReport()
    {
        var report = StiNetCoreDesigner.GetReportObject(this);

        var reportString = report.SaveToString();

        try
        {
            System.IO.File.WriteAllText(StiNetCoreHelper.MapPath(this, $"Reports/TwoSimpleListsRed.mrt"),
                reportString);
            return StiNetCoreDesigner.SaveReportResult(this);
        }
        catch (Exception e)
        {
            return StiNetCoreDesigner.SaveReportResult(this, "Error at saving: " + e.Message);
        }
    }
}
//DesignerComponent

Code: Select all

import {Component, OnInit} from '@angular/core';

declare var Stimulsoft: any;

@Component({
  selector: 'app-designer',
  templateUrl: './designer.component.html',
  styleUrls: ['./designer.component.css']
})
export class DesignerComponent implements OnInit {

  options: any;
  designer: any;

  constructor() {
  }

  ngOnInit() {
    this.renderHtml();
  }

  private renderHtml() {

    this.options = new Stimulsoft.Designer.StiDesignerOptions();

    //this.options.formValues = {__ReportName: params.get('reportId')};
    this.designer = new Stimulsoft.Designer.StiDesigner(this.options, 'MainDesigner', false);

    this.designer.renderHtml('designer');
  }
}

Also there is a wrong request to localhost:5001/undefined in preview page:
a.PNG
a.PNG (12.67 KiB) Viewed 1972 times

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular

Posted: Tue Apr 07, 2020 2:33 pm
by Lech Kulikowski
Hello,

Please check that CSS files were added.

Thank you.

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular

Posted: Wed Apr 08, 2020 7:53 am
by rabbal
Is There any reason to reference CSS files explicitly? these style files will render at runtime by DesignerController and StiNetCoreDesigner.ProcessRequestResult method.

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular

Posted: Fri Apr 10, 2020 11:47 am
by Lech Kulikowski
Hello,

We need some additional time to investigate the issue.

Thank you.
#1820

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular

Posted: Tue Jun 02, 2020 7:34 am
by Lech Kulikowski
Hello,

The issue with some icons is fixed and will be available in the release 2020.3.1 within a week.

Also, please correct your code as:

Code: Select all

[HttpPost]
        public IActionResult Post()
        {
            var requestParams = StiNetCoreDesigner.GetRequestParams(this);

            if (requestParams.Component == StiComponentType.Viewer)
                return StiNetCoreViewer.ProcessRequestResult(this);

            switch (requestParams.Action)
            {
                case StiAction.SaveReport:
                    return SaveReport();
                case StiAction.GetReport:
                    return LoadReport(requestParams);
                case StiAction.PreviewReport:
                    return PreviewReport(requestParams);
                default:
                    return StiNetCoreDesigner.ProcessRequestResult(this);
            }
        }
Thank you.