The intention is to have a dynamic set of reports which will be both designed and viewed within the application. I am trying to set up the viewer now. The URL to view a particular report should be https://localhost:5001/reports/viewer/{reportId} but as I struggled with the routing, https://localhost:5001/reports/viewer/index/{reportId} works with [Route("Reports/Viewer/[action]/{id}")] in the controller and RouteTemplate = "Reports/Viewer/{action}/{id}" in the cshtml view. As a side note: this was the only combination of Route and RouteTemplate which I managed to get working and that is in combination with ViewBag as somehow the id parameter in GetReport only gets "{id}" value. Is there a better way to do this?
But the main problem is that when I call the page, this is what I get:
After choosing the view mode to Single Page, I can see the report but I cannot scroll in it.
Here is my controller:
Code: Select all
namespace ArcheoLamia.Reports.Pages
{
using Microsoft.AspNetCore.Mvc;
using Serenity.Web;
using Stimulsoft.Report;
using Stimulsoft.Report.Mvc;
using System.Data;
// [PageAuthorize(typeof(Entities.ReportsRow))]
[Route("Reports/Viewer/[action]/{id}")]
public class ViewerController : Controller
{
static ViewerController()
{
// How to Activate
//Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnO...";
//Stimulsoft.Base.StiLicense.LoadFromFile("license.key");
//Stimulsoft.Base.StiLicense.LoadFromStream(stream);
}
public IActionResult Index(string id)
{
if (id != "undefined")
ViewBag.Id = id;
return View(MVC.Views.Reports.Viewer.ViewerIndex);
}
public IActionResult GetReport(string id)
{
StiReport report = new StiReport();
report.Load(StiNetCoreHelper.MapPath(this, $"Reports/{TempData["Id"]}.mrt"));
return StiNetCoreDesigner.GetReportResult(this, report);
}
public IActionResult ViewerEvent()
{
return StiNetCoreViewer.ViewerEventResult(this);
}
}
}
Code: Select all
@using Stimulsoft.Report.Mvc;
@using Stimulsoft.Report.Web;
@using Stimulsoft.System.Web.UI.WebControls;
@{
ViewBag.Title = "Stimulsoft Reports.Web Demo";
if (ViewBag.Id != null) {
TempData["Id"]=ViewBag.Id;
}
}
@Html.StiNetCoreViewer("StiMvcViewer1", new StiNetCoreViewerOptions()
{
Actions =
{
GetReport = "GetReport",
ViewerEvent = "ViewerEvent"
},
Server =
{
RouteTemplate = "Reports/Viewer/{action}/{id}"
},
//Localization = "Modules/Reports/cs.xml",
Appearance =
{
BackgroundColor = System.Drawing.Color.FromArgb(0xe8, 0xe8, 0xe8),
ScrollbarsMode = true
},
Toolbar =
{
DisplayMode = StiToolbarDisplayMode.Separated,
ShowDesignButton = false,
ViewMode = StiWebViewMode.SinglePage
}
})