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

[Solved] Dynamic Columns

1 Answer 100 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.
ultramods
Top achievements
Rank 1
ultramods asked on 27 Aug 2010, 04:31 PM
I would like to produce a table similar to this one: http://www.telerik.com/help/silverlight/gridview-how-to-access-child-gridview.html

However rather than the person object having properties such as FirstName, LastName, Title etc Person would have a collection of Attributes.

Something like
Public class Person
{
    Public Person()
    {
            Id = 2
            Children = new ObservableCollection<Person>();
            Children.Add(personNancy);
            Attributes = new ObservableCollection<Attribute>();
            Attributes .Add(new Attribute(){Name = "First Name", Value="Andrew"});
            Attributes .Add(new Attribute(){Name = "Last Name", Value="Fuller"});
            Attributes .Add(new Attribute(){Name = "Title", Value="Vice President, Sales"});..............
    }
    
    public int Id;
    public Person parent;
   
    public ObservableCollection<Person> Chldren
    {
        get, set;
    }

    public ObservableCollection<Attribute> Attributes 
    {
        get, set;
    }

}

For each person I would like to create a cell for each attribute. Is this possible using DataTemplates rather than programming in code behind or view model, I know that I could create a datatable but I would prefer to bind my Person object directly to the Grids Itemssource.

 Id |  First Name | Last Name | Title
------------------------------------------------------
2   | Andrew       | Fuller         | Vice President, Sales (can then expand Andrew to find child Nancy)
             Id |  First Name | Last Name | Title
                ------------------------------------------------------
                1   | Nancy         | Davolio      | sales Rep

Thank you in advance for any help.

1 Answer, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 30 Aug 2010, 03:02 PM
Hi stuart armstrong,

 Unfortunately there is no way to create a code-less solution for your scenario.

Kind regards,
Yavor Georgiev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
ultramods
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Share this question
or