I have used syncfusion report viewer but while loading report in view there is Excepition thrown
the screen snapshot or exception i attached with thread
the view code is:
<link rel='nofollow' href="http://cdn.syncfusion.com/js/web/flat-azure/ej.web.all-latest.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js" type="text/javascript"></script>
<script src="http://cdn.syncfusion.com/js/web/ej.web.all-latest.min.js" type="text/javascript"></script>
<script src=" http://cdn.syncfusion.com/js/web/ej.unobtrusive-latest.min.js" type="text/javascript"></script>
@using Syncfusion.MVC.EJ
@using Syncfusion.JavaScript.Models
@using Syncfusion.JavaScript
@*@using Syncfusion.JavaScript.ReportViewer*@
<div style="width: 100%">
@(Html.EJ().ReportViewer("viewer").ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Local)
.ReportPath("Customer.rdlc")
.ReportServiceUrl("api/ReportApi")
.DataSources(ds => ds.Name("Customer").Value(ViewData["cust"]).Add()))
</div>
and the code of controlle as :
public class ReportApiController : Controller, IReportController
{
public ActionResult Report()
{
ViewData["cust"] = GetList();
return View();
}
public object PostReportAction(Dictionary<string, object> jsonResult)
{
return ReportHelper.ProcessReport(jsonResult, this);
}
//Get action for getting resources from the report
[System.Web.Http.ActionName("GetResource")]
[AcceptVerbs("GET")]
public object GetResource(string key, string resourcetype, bool isPrint)
{
return ReportHelper.GetResource(key, resourcetype, isPrint);
}
//Method will be called when initialize the report options before start processing the report
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
//You can update report options here
}
//Method will be called when reported is loaded
public void OnReportLoaded(ReportViewerOptions reportOption)
{
//You can update report options here
}
[HttpPost]
public List<CustomerVM> GetDataForReport()
{
return GetList();
}
private List<CustomerVM> GetList()
{
var list = new List<CustomerVM>();
var cust1 = new CustomerVM { Id = 1, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust2 = new CustomerVM { Id = 2, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust3 = new CustomerVM { Id = 3, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust4 = new CustomerVM { Id = 4, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust5 = new CustomerVM { Id = 5, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust6 = new CustomerVM { Id = 6, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust7 = new CustomerVM { Id = 7, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust8 = new CustomerVM { Id = 8, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
var cust9 = new CustomerVM { Id = 9, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
list.Add(cust1);
list.Add(cust2);
list.Add(cust3);
list.Add(cust4);
list.Add(cust5);
list.Add(cust6);
list.Add(cust7);
list.Add(cust8);
list.Add(cust9);
return list;
}
}
and i have set application startup page in Global.aspx.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Login", action = "Login", id = UrlParameter.Optional } // Parameter defaults
);
}
Attachment:
Image1_2744d245.rar