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

How to bind List within the list?

3 Answers 1034 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pratik
Top achievements
Rank 1
Pratik asked on 08 Sep 2015, 11:50 AM

I have two List : 1)  ListPolicies, (Outer list, parent list)

                           2) ListBrokers (inner list, child list)

 

Class DataBind
{
public list <Policy> PolicyList {get;set;}
}

class Policy
{
public PolicyNumber {get;set;}
public PolicyName {get;set;}
public List<Broker> {get;set;}
}

class Broker
{
public Name {get;set;}
public Address {get;set;}
}​

 

bind data to parent list

ListPolicies.DataSource = defaultReportViewModel.PlanProvider.PolicyList;​

 Now i want to bind data childlist, how to achieve this thing???

 

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 08 Sep 2015, 02:08 PM
Hello Patrik,

When there is another business object property within your business object we do not drill down into the hierarchy. To use the inner object you have to bind a Data Item to it using expressions and Bindings. For more detailed information, please follow the Use DataObject as data source for nested data items (Table, List, Crosstab, Graph) section of the How to use ReportItem.DataObject property in expressions  article. This way you can bind the DataSource property of a data item to a given object/collection property from your business object and the data item will display the inner items.
In case you have multiple levels of nested objects, you will also need to data items in multiple levels in the report.
When you add a binding for the DataSource property of a nested data item (List, Table, Report), the data fields will not be available during design-time and you will need to write them down manually based on your business object structure.

In your particular scenario you can add the following binding to the broker list's DataSource property:

Property path: DataSource
Expression: = ReportItem.DataObject.Brokers

where the Brokers property contains a list of Broker objects:
class Policy
{
    public string PolicyNumber { get; set; }
    public string PolicyName { get; set; }
    public List<Broker> Brokers { get; set; }
}


Regards,
Nasko
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
Jonathan
Top achievements
Rank 1
answered on 03 Jun 2019, 02:56 PM
Current link: https://docs.telerik.com/reporting/data-items-how-to-use-data-object
0
Silviya
Telerik team
answered on 04 Jun 2019, 06:41 AM
Hello Jonathan,

Thank you, the article's link has been updated. 
Also, it might help checking How to Databind to Collection Properties KB article also.

Best Regards,
Silviya
Progress 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
Pratik
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Jonathan
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or