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

[Solved] DataGridTextColumn with binding to derived-class properties

2 Answers 118 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Thomas
Top achievements
Rank 1
Thomas asked on 06 Feb 2014, 05:18 AM
Hi,

I have the following situation: I'm bindind the RadDataGrid.ItemsSource to an ObserableCollection, which is templated with the base class of my data objects:

ObservableCollection<BaseItemModel> myCollection = new ...

This collection was filled before with concrete data objects like 
  
 myCollection.Add(new ConcreteItemModel())

whereas ConcreteItemModel derives from BaseItemModel.

When I'm now adding DataGridTextColumns to the RadDataGrid, only these column contents are being displayed, which are bound to base class properties (BaseItemModel). All Columns bound the properties of the derived class are not showing any content.

Using a DataGridTemplateColumn instead, it works. But in this case I would loose all build-in functionality (especially the filtering). 

Any help or advise would be appreciated :-)

Many thanks in advance!

Ciao

Thomas

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivaylo Gergov
Telerik team
answered on 07 Feb 2014, 10:36 AM
Hi,

Currently the RadDataGrid uses the type that is used on the initialization of the collection(in this case the BaseItemModel) as a contract. The only solution would be to create a collection of ConcreteItemModel objects. I will forward your feedback to our development team to further considerate extending the current logic.

Let me know if I can assist you in some other way. I have also updated your Telerik points for your valuable feedback.

Regards,
Ivaylo Gergov
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Thomas
Top achievements
Rank 1
answered on 08 Feb 2014, 06:01 AM
Hi Ivaylo,

many thanks for your reply!

I changed my implementation regarding your suggestion by binding an "object" typed Property in the base part which is created and filled as ObservabelCollection<ConcreteItemModel>in the concrete part of my app. And now it works perfectly :-)

So again, many thanks for your help!

Ciao

Thomas

Tags
Grid for XAML
Asked by
Thomas
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or