Hello Telerik Team,
I am presently converting my crystal reports to telerik reports.But previously crystal reports datasource was sql stored procedures and select statements but now
I am planning to have a datasource as sharepoint list.Is there any sample on how we can do that.
I appreciate your help.
Look forward from you.
Thank you
Smith
6 Answers, 1 is accepted
Preparing the data that you would use to feed the report is entirely up to the developer and not related to the product itself. Supported object types that can be used as datasource are listed in the following help article.
All the best,
Steve
the Telerik team
Hello Telerik Team,
I got the Datatable from the sharepoint list.But how do i bind this datatable to the telerik report.
I am new to telerik reporting.Do i need to intialize reportviewer or anything else.
Pls find my code below :
SPSite oSite = new SPSite("sharepointsiteurl");
SPWeb oWeb = oSite.OpenWeb();
listitems = oWeb.Lists["customlist"].Items;
oWeb.AllowUnsafeUpdates = true;
DataTable DTable = new DataTable();
DTable = listitems.GetDataTable();
this.DataSource = DTable;
I am wrting the above code in the .csfile of the report.I guess i need to bind this datatable to something
in ascx.cs file to display on a webpart.
can you give any sample on how to do this.
Thank you
Smith.
For backwards compatibility reasons Telerik Reporting supports binding directly to IEnumberable/IListSource objects (incl. arrays, collections, DataSet, DataTable, DataView, DbDataAdapter). However we highly recommend using the ObjectDataSource Component instead that can handle this types of data sources.
Specifically review the following help article: How to: Bind to a DataTable.
Also you should be aware that Telerik Reports are standard .NET classes and if you need to show the reports in your application, you can use one of the available report viewers, in your case the ASP.NET report viewer: Embedding the Web Report Viewer on a Web Form.
Sincerely yours,
Steve
the Telerik team
Hello Telerik team,
Thank you for the response.I was able to use list as a datasource for the report using CAML query
Thank you for the support.
Smith
Could somebody please update the solution to this process? I am not able to properly bind a DataTable to a report viewer that is embedded within a Sharepoint 2010 WebPart. (using Telerk.Reporting.dll version 6.1.12.820)
I have followed the deployment/configuration steps for getting the report viewer to work properly within shareopint -- and it is appearing (just the underlying data is not that I'm binding is not).
I have also followed the instructions on how to bind a dataTable to a report viewer with no success.
http://www.telerik.com/help/reporting/object-data-source-how-to-bind-to-data-table.html
I have copied the code directly from this link (replacing the GetData() method with my own to create a simply 3 column, 1000 row table).
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExportListUserControl.ascx.cs" Inherits="CADLibraryWebPart.ExportList.ExportListUserControl" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2012.2.815.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.ReportViewer.WebForms, Version=6.1.12.820, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
Namespace="Telerik.ReportViewer.WebForms" TagPrefix="telerik" %>
<div style="height: 500px;">
<telerik:ReportViewer ID="ReportViewer1" runat="server" style="border:1px solid #ccc;" width="99%" height="99%"></telerik:ReportViewer>
</div>
private DataTable createData()
{
DataSet ds = new DataSet();
ds.Tables.Add();
DataTable table = ds.Tables[0];
int columnCount = 3;
int rowCount = 1000;
//Add columns
for (int column = 0; column <= columnCount - 1; column++)
{
table.Columns.Add("Column" + (column + 1).ToString(), typeof(string));
}
//Add rows
for (int row = 0; row <= (rowCount - 1); row++)
{
string[] rowVals = (string[])Array.CreateInstance(typeof(string), columnCount);
DataRowCollection rowCollection = table.Rows;
for (int column = 0; column <= columnCount - 1; column++)
{
rowVals[column] = "value_" + (column + 1).ToString() + "_" + (row + 1).ToString();
}
table.Rows.Add(rowVals);
}
return ds.Tables[0];
}
private void BindTelerikReport()
{
// Creating and configuring the ObjectDataSource component:
var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = createData(); // GetData(); // GetData returns a DataSet with three tables
// Creating a new report
Telerik.Reporting.Report report = new Telerik.Reporting.Report();
// Assigning the ObjectDataSource component to the DataSource property of the report.
report.DataSource = objectDataSource;
// Use the InstanceReportSource to pass the report to the viewer for displaying
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
reportSource.ReportDocument = report;
// Assigning the report to the report viewer.
ReportViewer1.ReportSource = reportSource;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindTelerikReport();
}
}
I would appreciate any help with this. Thanks you!
I would appreciate any help with this. Thanks you!
You should create an instance of your own report i.e. MyReport report = new MyReport() where MyReport is a report you have already created via the report designer and you have added TextBox items with appropriate Expressions. There is no AutoGenerateColumns feature in Telerik Reporting like with Grid controls, where you just provide data source to the grid and it automatically reflects the columns in your database and creates them automatically. The report is a template that you should create yourself (be it with the report designer or code). See Quickstart and Designing Reports help sections for more information.
Kind regards,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >