Binding

5 posts, 0 answers
  1. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 28 Nov 2011 Link to this post

    Hi all,

    I'm using a RadTreeListView control that is bound to a datasource that contains many levels of objects. The objects are linked with an ObservableCollection<T> Items property. I have declared this property in the control so that it knows how to load the children


    <telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:TreeListViewTableDefinition ItemsSource="{Binding Items}" />
    </telerik:RadTreeListView.ChildTableDefinitions>

    Then, I'm binding the columns of the TreeListView to a property, say Name, but unfortunately not all objects in my hierarchy have such a property. For now, everything is working as expected (nothing is displayed), but a lot of BindingExceptions are raised (which is ok since the property doesn't exist on some objects) but I've got the impression that it slows down the loading process (it can take many seconds until the grid is generated even if I don't have so many data).

    How can I workaround this? With a Converter or something like this ?

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Nov 2011 Link to this post

    Hello Nico,

     Would it be possible for you to send us a very simple sample project, showing your data Hierarchy? That way we could think of a possible workaround.

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 02 Dec 2011 Link to this post

    Euh, my hierachy is a bit complex, but the same problem is raised with something as simple as

        public class Department
        {
            public Department()
            {
                this.Items = new List<Employee>();
            }

            public string Id { get; set; }

            public string Name { get; set; }

            public IList<Employee> Items { get; set; }
       }

        public class Employee
        {
            public Employee()
            {
            }

            public string Id { get; set; }
        }

    If I do a binding on the Name property, it will work for the Department but not for the Employee (nothing is displayed in the cells and this is exactly what I want since this property doesn't exist on the Employee level). But for each cell, a BindingException is raised and I've got the impression that this could slow down the whole process, especially if there is a lot of data...

    Do you see the problem?
    Cheers,

    Nicolas

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 06 Dec 2011 Link to this post

    Hi Nico,

    As I look at the structure of your data, I would recommend you to use a RadGridView with Hierarchy or RowDetails template. That way there will be not such problems.

    Another way to avoid the errors would be to define just empty Name and Employees properties for the Employee.

    Regards,
    Didie
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. AKROS
    AKROS avatar
    68 posts
    Member since:
    Oct 2011

    Posted 07 Dec 2011 Link to this post

    Hi Didie,

    Thanks for your answer.
    I have to use the RadTreeListView... We are using a lot of functionnalities of that control. Switching to the RadGridView is thus not possible.

    In fact my hierarchy is much more complex than the example above (I've got six levels of objects) and adding two or three properties to all objects just to avoid BindingException is conceptually not optimal I guess.

    If you've got another idea, don't hesitate to post it here...
    Thanks for your help and your time.

    Greetings,
    Nicolas
Back to Top
DevCraft banner