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

Binding

4 Answers 70 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
AKROS
Top achievements
Rank 1
AKROS asked on 28 Nov 2011, 02:16 PM

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 ?

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 29 Nov 2011, 05:12 PM
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 >>

0
AKROS
Top achievements
Rank 1
answered on 02 Dec 2011, 08:10 AM

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

0
Dimitrina
Telerik team
answered on 06 Dec 2011, 04:08 PM
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 >>
0
AKROS
Top achievements
Rank 1
answered on 07 Dec 2011, 09:32 PM
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
Tags
TreeListView
Asked by
AKROS
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
AKROS
Top achievements
Rank 1
Share this question
or