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

GridView Hierarchy Data Grid

2 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Leo
Top achievements
Rank 2
Leo asked on 29 Nov 2010, 01:38 PM

<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding}" Grid.Row="1" GroupPanelForeground="Red" >
            <telerik:RadGridView.ChildTableDefinitions>
                <telerik:GridViewTableDefinition>
                    <telerik:GridViewTableDefinition.Relation>
                        <telerik:PropertyRelation ParentPropertyName="Students"/>
                    </telerik:GridViewTableDefinition.Relation>
                </telerik:GridViewTableDefinition>
            </telerik:RadGridView.ChildTableDefinitions>
        </telerik:RadGridView>

In my Linq to SQL Class I have Students Table and Subjects.

Students field has Student ID, StudentFN, StudentLN while Subjects has SubjectID, Subject, Professor, StudentID.

I have associated the two student id.

My .xaml.cs is 
public partial class MainWindow : Window
    {
        ObservableCollection<MyObject> _MyObject = new ObservableCollection<MyObject>();
        DataContextDataContext context1 = new DataContextDataContext();
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new ObservableCollection<MyObject>();
            RadGridView1.Filtered+=new EventHandler<GridViewFilteredEventArgs>(RadGridView1_Filtered);
            foreach (var p in context1.Students)
            {
                _MyObject.Add(new MyObject { ID = p.StudentID, Name = p.StudentFN });
            }
        }
 
        void RadGridView1_Filtered(object sender, GridViewFilteredEventArgs e)
        {
            RadGridView1.ItemsSource = _MyObject;
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
 
        }
    }
 
    public class MyObject
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

I tried running the gridview but it doesn't show the level 2 data grid for the each record nor the column headers of the subject table.

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Nov 2010, 02:32 PM
Hi,

 You should have Students property for MyObject which such configuration. 

Greetings,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Leo
Top achievements
Rank 2
answered on 29 Nov 2010, 02:44 PM
What do you mean?
Tags
GridView
Asked by
Leo
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Leo
Top achievements
Rank 2
Share this question
or