<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ReportingExtensions" type="Syncfusion.Reporting.Extensions, Syncfusion.Report.Portable" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<ReportingExtensions>
<DataExtension>
<Extension Name="WebAPI" Assembly="Syncfusion.Reporting.DataExtensions.WebAPI" Type="Syncfusion.Reporting.DataExtensions.WebAPI.WebAPIExtension">
<Properties>
<Add Key="QueryDesignerEnabled" Value="true"/>
<Add Key="QueryFilterEnabled" Value="false"/>
<Add Key="QueryExpressionEnabled" Value="false"/>
<Add Key="QueryJoinerEnabled" Value="false"/>
<Add Key="QueryColumnEdit" Value="false"/>
</Properties>
</Extension>
</DataExtension>
</ReportingExtensions>
</configuration> |
$(function () {
$(document.body).bind('submit', $.proxy(formSubmit, this));
$(window).bind('beforeunload', $.proxy(windowUnload, this));
$("#container").ejReportDesigner(
{
serviceUrl: '../../api/Report',
create: 'controlInitialized',
reportDataExtensions: [{
className: 'WebAPIDataSource',
name: 'WebAPI',
imageClass: 'e-reportdesigner-datasource-webapi',
displayName: 'WebAPI'
}],
});
}); |
<ej-report-designer id="reportdesigner1" create="controlInitialized" service-url="../Home" report-data-extensions="@ViewBag.ReportDataExtensions">
</ej-report-designer>
<ej-script-manager></ej-script-manager> |
public ActionResult Index()
{
ViewBag.ReportDataExtensions = new List<Syncfusion.JavaScript.Models.ReportDesigner.ReportDataExtensionsModule>();
var ReportDataExtension = new Syncfusion.JavaScript.Models.ReportDesigner.ReportDataExtensionsModule();
ReportDataExtension.Name = "WebAPI";
ReportDataExtension.ClassName = "WebAPIDataSource";
ReportDataExtension.ImageClass = "e-reportdesigner-datasource-webapi";
ReportDataExtension.DisplayName = "WebAPI";
ViewBag.ReportDataExtensions.Add(ReportDataExtension);
return View();
} |
Query |
Response |
Thanks for this, I was able to add the web api extension in my project. I also tried your project and works at a point, then it displays error related to System.Web assembly as its .net framwork. See screenshot. This error is both in your sample and my project. |
We will validate this issue and provide the solution for this on March 14, 2019
|
Also after creating web api datasource how do I query my records? I am currently using this API to get JSON data back:
http://northwind.servicestack.net/customers.json |
Please refer the below help documentation which contains how to query the records with WebAPI,
Please find the example hosted WebAPI URL to test on your side,
|
{
"Guests": [
{
"Name": "Jack",
"Address":
{
"City": "London"
}
},
{
"Name": "David",
"Address":
{
"City": "Swansea"
}
},
]
}
Query |
Response | ||
1. when using this json file as an example: http://northwind.servicestack.net/customers.json for web api, I am unable to select child objects. I think the code for web api's json parsing requires that the json is flat and there are no child elements in it. I also checked this in line 440 method private DataTable JsonStringToDataTable(string jsonString) { ... } |
we were unable to achieve your requirement of nested level of json value fields in Web API Datasource hence we have logged a feature request on this, and it can be tracked through our feedback portal below.
At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented.
If you have any more specification/suggestions to the feature request you can add it as a comment in the portal.
| ||
2. When creating web api data source I can not see "API query builder" and "Code Mode" as per your example here there are many options which are not visible to me: https://help.syncfusion.com/report-platform/reportdesigner/web/how-to/web-api-datasource |
We need to pass the queryDesignerOption for report designer to show the query builder as shown in below code example.
| ||
3. I want to load the report rdl files dynamically when user views a certain report. When I try to load the report using the stream in this method: public void OnReportLoaded(ReportViewerOptions reportOption) using code reportOption.ReportModel.Stream the report still expects a file path and shows error that file not found. |
We can able to change the report path and render the report in same controller. We can able We have prepared the simple sample with drop down list to change the report dynamically when using the setModel method in client side. and it can be downloaded from below location.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/ReportSample_core_2.0-1780446478
Please find the below code example for how to change the reports using setModel method in client side.
Index.cshtml
Please find the below code example for how to pass that report path to get the stream in controller side.
HomeController.cs
Note: In above sample we have achieve to change the reports dynamically. Could you please modify above sample with your requirement.
| ||
4. Dynamically adding headers to report viewer and designer for example we need to add JWT token header for the logged in user. Where do we add that when the report viewer or designer is being opened? |
We can able to get the customer header from client to server using ajaxBeforeLoad event as shown in below code examples in ASP.NET Core application for report viewer and report designer.
Default.aspx:
ReportApiController.cs
|
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ReportingExtensions" type="Syncfusion.Reporting.Extensions.Configuration.Extensions, Syncfusion.Reporting.Web" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<ReportingExtensions>
<DataExtension>
<Extension Name="WebAPI" Assembly="Syncfusion.Reporting.DataExtensions.WebAPI" Type="Syncfusion.Reporting.DataExtensions.WebAPI.WebAPIExtension">
<Properties>
<Add Key="QueryDesignerEnabled" Value="true"/>
<Add Key="QueryFilterEnabled" Value="false"/>
<Add Key="QueryExpressionEnabled" Value="false"/>
<Add Key="QueryJoinerEnabled" Value="false"/>
<Add Key="QueryColumnEdit" Value="false"/>
</Properties>
</Extension>
</DataExtension>
</ReportingExtensions>
</configuration> |