Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Stimulsoft Reports.WEB discussion
Post Reply
rabbal
Posts: 5
Joined: Sun Apr 05, 2020 9:17 am

Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by rabbal »

Hello,

I'm using StiDesigner and StiViewer of Stimulsoft.Reports.Web.NetCore package with Angular like your "Web API with Angular" sample for StiViewer in github and as result of my debugging on StiVeiwer it is possible to send formValues to backend like below:

Code: Select all

this.options = new Stimulsoft.Viewer.StiViewerOptions();
this.options.formValues = {__ReportId: 'ReportId'};
//or this.options.routes= {__ReportId: 'ReportId'};
this.viewer = new Stimulsoft.Viewer.StiViewer(this.options, 'MainViewer', false);
this.viewer.renderHtml('viewer');
I have same expectation from StiDesigner to send formValues to responsible backend, but doesn't work and requestParams.FormValues is null on backend.

designer code:

Code: Select all

this.options = new Stimulsoft.Designer.StiDesignerOptions();
this.options.formValues = {__ReportId: 'ReportId'};
this.designer = new Stimulsoft.Designer.StiDesigner(this.options, 'MainDesigner', false);
this.designer.renderHtml('designer');
Thank you.
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by Lech Kulikowski »

Hello,

Please try to set the options.Server.PassFormValues=true option for the designer on the server side.

Thank you.
rabbal
Posts: 5
Joined: Sun Apr 05, 2020 9:17 am

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by rabbal »

Hello,

I have already set it up

Code: Select all

var options = new StiNetCoreDesignerOptions
{
    Theme = StiDesignerTheme.Office2013WhiteBlue,
    Server =
    {
        UseCompression = true,
        PassFormValues = true,
        UseCacheForResources = true
    }
};

return StiNetCoreDesigner.GetScriptsResult(this, options);
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by Lech Kulikowski »

Hello,

Thank you for the information.
EBooksWorld.ir

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by EBooksWorld.ir »

We encounter the same bug. when we set PassFormValues = true, the following exception rises.

Code: Select all

InvalidCastException: Unable to cast object of type 'Microsoft.Extensions.Primitives.StringValues' to type 'System.IConvertible'.
System.Convert.ToDouble(object value)
I reversed the designer source code and found the problem in StiNetCoreDesigner class on RenderJsonParameters method.

Code: Select all

 if (this.options.Server.PassFormValues && this.htmlHelper.ViewContext.HttpContext.Request.Method == "POST")
      {
        foreach (string key in (IEnumerable<string>) this.htmlHelper.ViewContext.HttpContext.Request.Form.get_Keys())
          hashtable2[(object) key] = (object) this.htmlHelper.ViewContext.HttpContext.Request.Form[key];
      }
The problem is that ToString() is missing on Form[key], so JSON Serialization failed.
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Stimulsoft.Reports.Web.NetCore StiDesigner with Angular and Send FormValues

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply