BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<div style="height: 525px;width: 100%;">
<ej-report-viewer id="reportviewer1" report-service-url="../Home" processing-mode="Local" rendering-begin="renderingBegin" ajax-before-load="ajaxBeforeLoad" />
</div>
<script type="text/javascript">
function ajaxBeforeLoad(event) {
var parameters = [{
name: 'CustomerID',
labels: ['29889'],
values: [29889],
nullable: false
}];
event.data = parameters;
};
</script>
<ej-script-manager></ej-script-manager> |
public partial class HomeController : Controller, IReportController
{
private IMemoryCache _cache;
private IHostingEnvironment _hostingEnvironment;
public string DefaultParam = null;
public HomeController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
{
_cache = memoryCache;
_hostingEnvironment = hostingEnvironment;
}
[HttpPost]
public object PostReportAction([FromBody] Dictionary<string, object> jsonResult)
{
if (jsonResult.ContainsKey("CustomData"))
{
DefaultParam = jsonResult["CustomData"].ToString();
}
return ReportHelper.ProcessReport(jsonResult, this, this._cache);
}
[ActionName("GetResource")]
[AcceptVerbs("GET")]
public object GetResource(ReportResource resource)
{
return ReportHelper.GetResource(resource, this, _cache);
}
[HttpPost]
public object PostFormReportAction()
{
return ReportHelper.ProcessReport(null, this, this._cache);
}
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string basePath = _hostingEnvironment.WebRootPath;
FileStream inputStream = new FileStream(basePath + @"\ReportsTemplate\Region.rdlc", FileMode.Open, FileAccess.Read);
reportOption.ReportModel.Stream = inputStream;
}
public void OnReportLoaded(ReportViewerOptions reportOption)
{
var parameters = new List<ReportParameter>();
if (DefaultParam != null)
{
parameters = JsonConvert.DeserializeObject<List<ReportParameter>>(DefaultParam);
}
if (parameters != null && parameters.Count > 0)
{
reportOption.ReportModel.DataSources.Clear();
reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData(Convert.ToInt32(parameters[0].Values[0])) });
}
}
} |