<form action="/api/ReportApi/ExportAction" method="post"> <input type="hidden" name="exporttype" value="PDF"/> <input type="submit" value="Export"/> |
public HttpResponseMessage ExportAction() { HttpResponseMessage _response = new HttpResponseMessage(); string writerFormat = HttpContext.Current.Request.Form["exporttype"]; string fileName = null; WriterFormat format; HttpContext httpContext = System.Web.HttpContext.Current; ReportWriter reportWriter = new ReportWriter(httpContext.Server.MapPath("~/ReportTemplate/drilldown.rdlc")); reportWriter.ReportProcessingMode = Syncfusion.EJ.ReportWriter.ProcessingMode.Local; ReportDataSourceCollection dataSources = new ReportDataSourceCollection(); dataSources.Add(new ReportDataSource { Name = "Customers", Value = Customers.GetData() }); reportWriter.DataSources = dataSources; fileName = "drilldown.pdf"; format = WriterFormat.PDF; reportWriter.Save(fileName, format, httpContext.Response); _response.StatusCode = System.Net.HttpStatusCode.OK; return _response; } } |
i would like to know if I can do the same but passing some datasources from the client side, as in the "Control Creation" example from javascript where you pass the Datasource as a Json array.
|
We have an API to pass the JSON data at client side in our ReportViewer control as shown in the below code example.
JS:
We have prepared the sample using DataSource value from client side and it can be downloaded from the below location,
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/Reportsample-1139699116.zip
Pleases refer to the below UG documentation for more detail,
You can obtain the JavaScript ReportViewer samples from the below build installed location,
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\version\JavaScript\reportsamples
Note: ReportWriter is a server side component and we could not initialize the ReportWriter control on client side. | |
Can I add an input and get it in the server side? |
We can also pass the DataSource in server side (WebAPI) as shown in the below code example,
WebAPI:
We have prepared a sample using DataSource value from server side and it can be downloaded from the below location,
|