How to bind List within the list?

4 posts, 0 answers
  1. Pratik
    Pratik avatar
    1 posts
    Member since:
    Aug 2015

    Posted 08 Sep 2015 Link to this post

    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???

     

  2. Nasko
    Admin
    Nasko avatar
    1050 posts

    Posted 08 Sep 2015 Link to this post

    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 a data source for nested data items (Table, List, Crosstab, Graph) section of the How to use ReportItem.DataObject property in expressions help 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 nest 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
  3. Jonathan
    Jonathan avatar
    11 posts
    Member since:
    Dec 2017

    Posted 03 Jun in reply to Nasko Link to this post

    Current link: https://docs.telerik.com/reporting/data-items-how-to-use-data-object
  4. Silviya
    Admin
    Silviya avatar
    354 posts

    Posted 04 Jun Link to this post

    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
Back to Top