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

Binding Grid to a sub class property

5 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alessandro
Top achievements
Rank 1
Alessandro asked on 07 Feb 2011, 07:14 PM
I am binding a grid to a list of objects such as:

ObservableCollection<ListItem> List

Wherby the ListItem is defined as:

public class ListItem
{
  public int Id;
  public string Title;
  // some other properties
  public Item TheItem;
}


the class "Item" is defined as:

public class Item
{
   public string Name;
   public string Location;
   public string Brand;
   public string Area;
}

Question 1

  I am binding my grid to the List of ListItems and therefore want to show its properties. I also want to show properties of the Item class it contains. My thinking is that the only way to do this is to dynamically construct the columns and bind them programatically. Am I correct in this thinking?

Question 2
 
  I am using a selector for specifing the detail panes. These Detail pains are setup to bind to an Item class, NOT to a ListItem class (this is becuase I reuse the usercontrol elswhere). Can I modify the binding of the Detail item so that it does not bind to the default ListItem (to which the grid items bind) but rather to a contained object of the ListItem? How and where would I do this? Thanks for all your help!

 -- xavier

5 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 08 Feb 2011, 04:26 PM
Hello Xavier,

You can bind the columns easily by using:

DataMemberBinding={Binding Item.Name}
DataMemberBinding={Binding Item.Location}, etc.

As for question 2 - do you mean the Row Details? If so, I am afraid this is not possible. The DataContext of the details presenter would be of type ListItem and you cannot change that. So, you could use the same Binding as the columns in this case.

Kind regards,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
sumit
Top achievements
Rank 1
answered on 02 Feb 2012, 06:09 PM
hi Veselin,

With your example below:
DataMemberBinding={Binding Item.Name}
DataMemberBinding={Binding Item.Location}, etc.

I am noticing if I do this, then these two columns are no longer sortable, and we can not filter them either. Is this a known functionality? What is the workaround? Please advice.

Thanks.
0
Vlad
Telerik team
answered on 03 Feb 2012, 07:34 AM
Hello,

 Are you using our latest official version - Q3 2011 SP1?

Greetings,
Vlad
the Telerik team

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

0
sumit
Top achievements
Rank 1
answered on 03 Feb 2012, 01:56 PM
Yes.
0
Yordanka
Telerik team
answered on 03 Feb 2012, 03:45 PM
Hi,

I've made a small project in order to reproduce the issue but sorting and filtering work as expected. Can you confirm that your scenario is the same? Is there something specific that I have missed?
 
Greetings,
Yordanka
the Telerik team

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

Tags
GridView
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
sumit
Top achievements
Rank 1
Vlad
Telerik team
Yordanka
Telerik team
Share this question
or