Binding nested lists

6 posts, 0 answers
  1. Andreas
    Andreas avatar
    7 posts
    Member since:
    Aug 2012

    Posted 13 Aug 2012 Link to this post

    This is probably just a noob question - and had I done a more thorough job reading through documentation, I'm sure I'd figure it out. However, we're running low on time so I need to check here.

    I have a class structure as shown below (very simplified):

    public class TestSuite
    {
        public String SomeProp { get; set; }
        public List<TestCase> TestCases { get; set; }
    }
      
    public class TestCase
    {
        public String SomeProp { get; set; }
        public Boolean SomeOtherProp { get; set; }
        public List<Message> TestCaseMessages { get; set; }
    }
      
    public class Message
    {
        public String SomeProp { get; set; }
        public Boolean SomeOtherProp { get; set; }
    }

    In my report I have the following (again simplified) structure

    TestSuite header 

    -  List (bound to TestSuite.TestCases)

      -  List (bound to TestCase.TestCaseMessages)

    The outer list (TestCases) works great and I can access properties without issue, however the inner list (bound to TestCaseMessages) never shows any data if I use a DataSource through the DataSource wizard. On the other hand, if I set a Binding on the inner ListBox's DataSource to Fields.TestCaseMessages (relying on the DataSource of the outer list) - I can manually write Fields.SomeProp in bindings on TextBoxes inside the inner list.

    I know this sounds a bit confusing - but what I would really like is for the DataSource setup to work through the wizard/property grid and not having to hack it manually. Am I doing something wrong here - or is this a bug?

    Regards,

    Andreas

  2. IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 14 Aug 2012 Link to this post

    Hello Andreas,

    Actually this is the current way Telerik Reporting handles such master - child data relations. In order to be easier for you to set the fields you can create a data source from TestCase.TestCaseMessages and assign it to the DataSource property of the List. Once this is done fill in all your Textboxes with the respective expressions. When you are ready just delete the data source and set the binding.

    Regards,
    IvanY
    the Telerik team

    BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

  3. Andreas
    Andreas avatar
    7 posts
    Member since:
    Aug 2012

    Posted 16 Aug 2012 Link to this post

    Hi Ivan,

    Thanks for the answer.

    Are there any plans to change this behavior to a more intuitive datasource-approach (like what is possible on top-level bindings)?

    Regards,

    Andreas

  4. IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 17 Aug 2012 Link to this post

    Hi Andreas,

    A binding is a dynamic expression and is used when some data is not known at design time and might be subject of change at runtime. It could even be data that will be generated at runtime. This gives great flexibility to your reports, but has some limitations, the most considerable one being the fact that you do not have design time support.

    When the data is not known at design time it is not possible to provide this kind of support so the best approach in general would be the one proposed above.

    Regards,
    IvanY
    the Telerik team

    BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

  5. Anna
    Anna avatar
    1 posts
    Member since:
    Nov 2018

    Posted 30 Nov 2018 in reply to IvanY Link to this post

    Can you give an example please how you set binding in this case? Thanks
  6. Silviya
    Admin
    Silviya avatar
    344 posts

    Posted 05 Dec 2018 Link to this post

    Hi Anna,

    Please refer to this excellent KB article on the topic with a given example - How to Databind to Collection Properties.

    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