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

no field selection for sub-objects if using ObjectDataSource

5 Answers 221 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 08 Dec 2015, 11:25 PM

Hi,

 I am using ObjectDataSource. I have 4 list objects inside that object.

 In the report design view, I can see all the properties (fields) inside that object but not other 4 sub-objects. How can I make those properties (fields) display in the selection window?

Thank you!

 

 

5 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 10 Dec 2015, 05:48 PM
Hello Robert,

The Data Explorer lists only the direct properties of the wrapped data object. In case of collection properties, you can use another data source component to get the available fields and design a data item.

Then bind the designed item to the collection property - How to Databind to Collection Properties.


I hope this information is helpful.

Regards,
Stef
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
0
Robert
Top achievements
Rank 1
answered on 10 Dec 2015, 08:18 PM

Thanks. I did that but it doesn't work. could you please point me a direction where I did wrong

 

1. add a table to a report

2. set DataSource of this table as "Contact" in the property

3. click on "Bindings" and add a new binding as "DataSource = Fields.Phone"

4. add a field inside the table, click on "Fields" in the Data Explorer and I still see "Contact" and "Phone" inside the Contact with only "Capacity" and "Count"

 

thanks!

 

 

0
Stef
Telerik team
answered on 11 Dec 2015, 04:35 PM
Hi Robert,

Please test to add a second ObjectDataSource which wraps the Phone business object. Then start a Table Wizard where the data source is the newly added ObjectDataSource. Once the Table item is designed, reset the Table.DataSource property in the property grid and apply the binding.

The attached video illustrates the above suggestion. The video can be previewed in IE.

Regards,
Stef
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
0
Robert
Top achievements
Rank 1
answered on 11 Dec 2015, 08:15 PM

Thanks for the video! but we cannot do that because we don't use data straight from edmx model. we create our own model and pass it in at the report code behind to and set this.DataSource = model, because we need to post-process data after getting data from SQL server and we try to use the same method from app too to make the methods reusable and sync with app. (I guess we cannot preview then because the viewmodel was not created yet?)

 If we create an second objectdatatsource, we can see fields without any problem; however, the team prefers to use only one datasource for the report and able to pick and choose in the future if we need to modify it to be easy maintenance. 

 

thanks!

 

0
Stef
Telerik team
answered on 12 Dec 2015, 02:43 PM
Hi Robert,

The report in the example uses only the data assigned to the report's DataSource. All nested data items's Datasource properties are bound to collection properties of the main business object.

The second data source component is used only for obtaining the data schema , required to design the nested Table item. After the task is accomplished and the Table.DataSource is set via binding you can delete the second data source component.


About previewing reports, if the report's DataSource is set at run-time to a data object created in the context of the application, the design preview may fail as it is executed in the context of VS. To have design-time preview, you can use mockup data as report's DataSource or get data in the report's NeedDataSource event.
At run-time you can create your data object and pass it to the report instance:
var data = GetData(0;
var report = new MyReport();//get a Telerik.Reporting.Report instance
report.DataSource = data;//will replace the default data source settings of the report only, nested data items preserve their data source settings
 
//display the report
var IRS = new InstanceReportSource(){ ReportDocument = report };


Regards,
Stef
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
Robert
Top achievements
Rank 1
Answers by
Stef
Telerik team
Robert
Top achievements
Rank 1
Share this question
or