Hi Guys,
I am new to telerik controls. I went through various post regarding telerik reporting but I am unable to find anything which suits my need. I am using MVC 5
with razor engine.I have UI from where user can select various options and on the basis of the options selected I fetch the data from the database using stored procedure. Now the problem I am facing is in binding the data with the report. Can anyone help me with the same.I created a small POC where I binded the report with the sqldatasource and also added 1 parameter which user can input from UI. It works perfectly but it is done using the wizard. I want to do the same thing programatically.
I have tried 2 approach for this. In first approach i tried to set the datasource from code behind but i am unable to get the reportviewer on code behind neither I am able to bind it using Viewbag.
In second approach i did a ajax call and tried to bind the result with the report in javascript but nothing worked. My page is as follows:
I am getting an error on page which is as follows:
Error creating report instance (Report = Telerik.Reporting.Examples.CSharp.TrackingReport, FITS.Web.Reports):
Report 'Telerik.Reporting.Examples.CSharp.TrackingReport, FITS.Web.Reports' cannot be resolved.
Can anyone help me with the same.
I am new to telerik controls. I went through various post regarding telerik reporting but I am unable to find anything which suits my need. I am using MVC 5
with razor engine.I have UI from where user can select various options and on the basis of the options selected I fetch the data from the database using stored procedure. Now the problem I am facing is in binding the data with the report. Can anyone help me with the same.I created a small POC where I binded the report with the sqldatasource and also added 1 parameter which user can input from UI. It works perfectly but it is done using the wizard. I want to do the same thing programatically.
I have tried 2 approach for this. In first approach i tried to set the datasource from code behind but i am unable to get the reportviewer on code behind neither I am able to bind it using Viewbag.
var instanceReportSource =
new
Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument =
new
TrackingReport();
instanceReportSource.Parameters.Add(
"ReceiptId"
, ReceiptId);
this
.ReportViewer1.ReportSource = instanceReportSource;
In second approach i did a ajax call and tried to bind the result with the report in javascript but nothing worked. My page is as follows:
@using Telerik.Reporting.Examples.CSharp
@{
ViewBag.Title = "Tracking Report";
Layout = null;
}
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1, maximum-scale=1"
/>
<
link
href
=
"~/Content/css/font-awesome/css/font-awesome.css"
rel
=
"stylesheet"
/>
<
script
src
=
"http://code.jquery.com/jquery-1.9.1.min.js"
></
script
>
<
link
href
=
"~/Content/kendo/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"~/Content/kendo/kendo.blueopal.min.css"
rel
=
"stylesheet"
/>
<!--kendo.all.min.js can be used as well instead of kendo.web.min.js and kendo.mobile.min.js-->
<
script
src
=
"~/Scripts/kendo/kendo.web.min.js"
></
script
>
<
style
>
#reportViewer1 {
left: 5px;
right: 5px;
top: 40px;
bottom: 5px;
overflow: hidden;
font-family: Verdana, Arial;
}
</
style
>
<
link
href
=
"~/ReportViewer/styles/telerikReportViewer-8.2.14.1204.css"
rel
=
"stylesheet"
/>
<
script
src
=
"http://code.jquery.com/jquery-1.9.1.min.js"
></
script
>
<
script
src
=
"~/ReportViewer/js/telerikReportViewer-8.2.14.1204.js"
></
script
>
<
div
class
=
"panel panel-default"
>
<
div
class
=
"panel-body"
>
<
div
class
=
"form-horizontal"
>
<
div
id
=
"invoiceIdSelector"
>
<
label
for
=
"invoiceId"
>Invoices</
label
>
<
select
id
=
"invoiceId"
title
=
"Select the Invoice ID"
>
<
option
value
=
"IN-0015"
>Invoice 1</
option
>
<
option
value
=
"IN-1015"
>Invoice 2</
option
>
<
option
value
=
"IN-2015"
>Invoice 3</
option
>
</
select
>
</
div
>
<
div
id
=
"ReceiptNumber"
>
<
label
for
=
"receiptNumber"
>ReceiptNumber</
label
>
<
select
id
=
"receiptNumber"
title
=
"Select the receipt number"
>
<
option
value
=
"RC-9022015"
selected
=
"selected"
>Receipt Number 1</
option
>
<
option
value
=
"RC-9022016"
>Receipt Number 2</
option
>
<
option
value
=
"RC-9022017"
>Receipt Number 3</
option
>
</
select
>
</
div
>
<
div
class
=
"row padding"
>
<
div
class
=
"row"
>
<
div
class
=
"col-md-12"
>
</
div
>
</
div
>
<
div
class
=
"row padding"
>
<
div
class
=
"col-md-12 text-center "
>
<
button
class
=
"primary-button"
type
=
"button"
onclick
=
"GenerateReport()"
>Generate Report</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
id
=
"reportViewer1"
>
loading...
</
div
>
<
script
src
=
"http://code.jquery.com/jquery-1.9.1.min.js"
></
script
>
<
script
>
$(document).ready(function () {
$("#reportViewer1").telerik_ReportViewer({
serviceUrl: "../api/reports/",
templateUrl: '../ReportViewer/templates/telerikReportViewerTemplate-8.2.14.1204.html',
reportSource: {
report: "Telerik.Reporting.Examples.CSharp.TrackingReport, FITS.Web.Reports",
parameters: { ReceiptNumber: $('#receiptNumber option:selected').val() }
},
viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
scale: 1.0,
ready: function () {
this.refreshReport();
}
});
});
function GenerateReport()
{
var receiptNumber = $("#receiptNumber option:selected").val();
var viewer = $("#reportViewer1").data("telerik_ReportViewer");
$.ajax({
type: "POST",
url: '/Common/GetReport',
content: "application/json; charset=utf-8",
dataType: "json",
data: { ReceiptNumber: receiptNumber },
traditional: true,
success: function (data) {
if (data.Result == "SUCCESS") {
viewer.reportSource(data);
viewer.refreshReport();
}
},
error: function (xhr, textStatus, errorThrown) {
}
});
}
</
script
>
<
script
src
=
"~/ReportViewer/js/telerikReportViewer-8.2.14.1204.js"
></
script
>
<
script
src
=
"~/Scripts/kendo/kendo.web.min.js"
></
script
>
I am getting an error on page which is as follows:
Error creating report instance (Report = Telerik.Reporting.Examples.CSharp.TrackingReport, FITS.Web.Reports):
Report 'Telerik.Reporting.Examples.CSharp.TrackingReport, FITS.Web.Reports' cannot be resolved.
Can anyone help me with the same.