This is a migrated thread and some comments may be shown as answers.

trdx report with objectdatasource

1 Answer 192 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 18 Dec 2015, 01:41 PM

Hi,

I am trying to show the teleik report with objectdatasource available only at runtime. 

Following is the code which I used. 

                             object jsonobj = getJsonObject();

                            SearchbyCondition oSearch = new SearchbyCondition();
                            List<SearchbyCondition> oListCond = oSearch.getSearchbyConditionReportFields(jsonobj);

                            // Creating and configuring the ObjectDataSource component:
                            Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
                            objectDataSource.DataSource = oListCond;// GetData returns a DataTable

                            // 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;


                            System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
                            settings.IgnoreWhitespace = true;
                            string localPath = Request.ApplicationPath + "Report/" + ReportName;
                            localPath = Server.MapPath(localPath);
                            XmlReader xmlReader = XmlReader.Create(localPath, settings);
                            Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
                            report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);

                            // 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;

                            // Calling the RefreshReport method in case this is a WinForms application.
                            ReportViewer1.RefreshReport();

I can see the report but without any data.

I tried using value="[Fields.BOPropertyName]" 

value="Fields.BOPropertyName" as well in trdx file

 In trdx file how can I give Objectdatasource TAG as while design it is not available.

as mentioned at http://www.telerik.com/help/reporting/connecting-to-data-working-with-data-at-design-time.html

"Data source available only at runtime" passage.

 

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 22 Dec 2015, 03:12 PM
Hi Amit,

The report's DataSource property can be modified after deserializing the TRDX file's content into a Telerik.Reporting.Report object.

Please see below some sample code you can use to fix this behavior. 
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(localPath, settings))
{
    Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
        new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
 
    report = (Telerik.Reporting.Report)
        xmlSerializer.Deserialize(xmlReader);

 report.DataSource = GetDataObject();
}


If you prefer to work with custom business objects in the Standalone Report Designer, please see Extending Report Designer. In general, you can build an assembly with your data access layer and then load this assembly on starting the Standalone Report Designer. As a result you will be able to browser the types declared in the external assemblies on configuring an Object/Entity/OpenAccess DataSource component.


We hope you will find this information helpful.

Regards,
Katia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Amit
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or