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

Data Explorer ObjectDataSource with Nested List View

4 Answers 409 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 03 Jan 2012, 11:30 PM
Hi,

I have an ObjectDataSource with Collection as follows:

public class Person
{
    public string FirstName {get; set;}
    public string LastName {get; set;}
    public List<Email> emails {get; set;}
}

public class Email
{
  public string Address {get; set;}
  public string Category {get;set}
}

A method returns a List<Person> that is used as the datasource for the report

In the Report Explorer I see the fields FirstName, Lastname and Email
However Email only gives me Capacity and Count and not Address and Category.  It seems that the Data Explorer cannot drill down to the Nested list of Emails and its properties.

Is there a way to set it up so that the Email fileds are exposed Data Explorer?  This way I was hoping to avoid using subreports which will get a object datasource  of "PersonEmails" from a method and use this in the details.

Thanks,
Peter



4 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 05 Jan 2012, 03:50 PM
Hello,

This isn't possible because the relation is one-to-many and Fields.Emails.Address wouldn't be a correct expression. What you can do is use a report item that supports data binding (like Table, Crosstab, List or SubReport) and set its data source with Bindings to ReportItem.DataObject.Emails which is the current DataObject (the current person's list of emails) and then in this table/crosstab/list you can use the expressions Fields.Address and Fields.Category.

Kind regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Tormod
Top achievements
Rank 1
answered on 24 Jan 2012, 11:10 PM
In my experience setting the databinding to the datasource property isn't enough to provide design time support within the data explorer if you, for example work on tweaking the innards of a list/crosstab using an ObjectDataSource.

I do it by creating a mock ObjectDataSource that returns the Email type and then assign it to the datasource property of the list. Then the data explorer will show correctly "Address" and "Category whilst you are working inside the list rows/table cells.

You basically set the DataSource property for the List/Tab twice. Both as a normal entry in the properties dialog and also through an entry in the "bindings" collection through which you bind "DataSource" to "= Fields.emails". Thus, the dataadapter set through the properties dialog will be overridden at runtime, but is still necessary to have support for field names at design time.
0
Nuwan
Top achievements
Rank 1
answered on 02 Oct 2013, 04:11 AM
HI Elian,

I tried the way you explained and it is working fine. But I need to give sub List as a object list.

 I am using a LINQ query to retrieve all data one time.
How can I list my sub class list data with master class data in the report?
Please reply..

I meant, my class strcuture is as follows.

 public class POLevelDeliveryOrderHistory
    {
       
        public List<POHistoryDeliveryOrderDetail> DeliveryOrderDetailList { get; set; }

        public WorkOrder ParentWorkOrder { get; set; }

        public DeliveryOrder DeliveryOrder { get; set; }

        public Customer Customer { get; set; }

        public string WorkOrderNumber { get; set; }

        public double SumAmount { get; set; }

        public double SumQuantity { get; set; }
    }

    public class POHistoryDeliveryOrderDetail
    {
    
        public virtual DeliveryOrderDetail DeliveryOrderDetail { get; set; }

        public virtual DeliveryOrder DeliveryOrder { get; set; }

        public virtual int DeliveryOrderID { get; set; }

        public virtual int DeliveryOrderLineID { get; set; }

        public virtual double Quantity { get; set; }

        public virtual decimal? UnitPrice { get; set; }

        public virtual WorkOrder WorkOrder { get; set; }

        public virtual WorkOrder ParentWorkOrder { get; set; }

        public virtual int? WorkOrderID { get; set; }
    }



Thanks,

Nuwan
0
KS
Top achievements
Rank 1
answered on 04 Oct 2013, 05:40 PM
Hi,

Check this Data Source Business Objects   

The way I do it is to add helper ObjectDataSources for each nested type and use them to make my Tables. When I am done I just change the DataSource to nothing and apply the binding to my main ObjectDataSource fields, and finally place the Table into the parent container.

- KS
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Elian
Telerik team
Tormod
Top achievements
Rank 1
Nuwan
Top achievements
Rank 1
KS
Top achievements
Rank 1
Share this question
or