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

Custom Hierarchy in GridView

4 Answers 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 07 Nov 2009, 06:52 AM
Hi

I'm trying to get a custom hierarchy going in the new Q3 Gridview.  The examples don't explain how to do this properly (the example under Custom Hierarchy is actually a Property Hierarchy).

Here's how I did it in the previous version:

        public FailedMessagesView() 
        { 
            InitializeComponent(); 
            FailedFaxGrid.TableDefinition.PreviewDataRecordCreate += FailedFaxTableDefinition_PreviewDataRowCreate; 
        } 
 
        private void FailedFaxTableDefinition_PreviewDataRowCreate(object sender, DataRecordCreateEventArgs e) 
        { 
            FailedMessagesViewModel fmVM = (FailedMessagesViewModel)DataContext; 
            SuppliersEntity theSupplier = (SuppliersEntity)e.Data; 
            ObservableCollection<MessagesCheckedEntity> theMessages = new ObservableCollection<MessagesCheckedEntity>
                fmVM.FailedFaxes.Where(m => m.fkidSupplier == theSupplier.idSupplier).ToList()); 
            if (theMessages.Count > 0) 
            { 
                e.IsExpandableRecord = true
                GridViewTableDefinition ffDefs = new GridViewTableDefinition(); 
                ffDefs.AutoGenerateFieldDescriptors = false
                ffDefs.DataSource = theMessages
 
                GridViewDataColumn checkBox = new GridViewDataColumn(); 
                checkBox.Name = "FailedFaxCheckValName"
                checkBox.Header = " "
                checkBox.IsFilterable = false
                checkBox.IsGroupable = false
                checkBox.IsReadOnly = true
                checkBox.CellStyle = (Style)FailedFaxGrid.FindResource("checkValueStyle"); 
                checkBox.Width = GridViewLength.Auto; 
                ffDefs.FieldDescriptors.Add(checkBox); 
 
                GridViewDataColumn JobNo = new GridViewDataColumn(); 
                JobNo.Name = "FailedFaxJobNoName"
                JobNo.Header = "Job"
                JobNo.IsFilterable = false
                JobNo.IsGroupable = false
                JobNo.IsReadOnly = true
                JobNo.DataMemberBinding = new Binding("DataRow[sgCommonName]"); 
                JobNo.Width = GridViewLength.Auto; 
                ffDefs.FieldDescriptors.Add(JobNo); 
 
                GridViewDataColumn task = new GridViewDataColumn(); 
                task.Name = "FailedFaxTaskName"
                task.Header = "Task"
                task.IsFilterable = false
                task.IsGroupable = false
                task.IsReadOnly = true
                task.DataMemberBinding = new Binding("DataRow[sgItemName]"); 
                task.Width = GridViewLength.Auto; 
                ffDefs.FieldDescriptors.Add(task); 
 
                GridViewDataColumn TaskNotes = new GridViewDataColumn(); 
                TaskNotes.Name = "TaskNotes"
                TaskNotes.Header = "Task Notes"
                TaskNotes.IsFilterable = false
                TaskNotes.IsGroupable = false
                TaskNotes.IsReadOnly = true
                TaskNotes.DataMemberBinding = new Binding("DataRow[mNotes]"); 
                TaskNotes.Width = new GridViewLength(1, GridViewLengthUnitType.Star); 
                TaskNotes.TextWrapping = TextWrapping.Wrap; 
                ffDefs.FieldDescriptors.Add(TaskNotes); 
 
                GridViewDataColumn ReceiptDetails = new GridViewDataColumn(); 
                ReceiptDetails.Name = "ReceiptDetails"
                ReceiptDetails.Header = "Failure Reason"
                ReceiptDetails.IsFilterable = false
                ReceiptDetails.IsGroupable = false
                ReceiptDetails.IsReadOnly = true
                ReceiptDetails.DataMemberBinding = new Binding("sgReciptDetails"); 
                ReceiptDetails.Width = new GridViewLength(1, GridViewLengthUnitType.Star); 
                ReceiptDetails.TextWrapping = TextWrapping.Wrap; 
                ffDefs.FieldDescriptors.Add(ReceiptDetails); 
                e.ChildTableDefinitions.Add(ffDefs); 
            } 
        } 

A warning pops up telling me that this method is obsolete, and doing it this way no longer works.

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Nov 2009, 06:57 AM
Hi James,

Please check this demo for more info:
http://demos.telerik.com/wpf/?GridView/Hierarchy/CustomHierarchy

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 09 Nov 2009, 07:50 AM
Hi Vlad

"I'm trying to get a custom hierarchy going in the new Q3 Gridview.  The examples don't explain how to do this properly (the example under Custom Hierarchy is actually a Property Hierarchy)."

Is what I posted. I've had a look at the examples already and they don't cover what I want to do.  I don't have a property in the entities that make up my main row that can be used to fill the hierarchy.  What I need to do is a custom hierarchy, as per the examples in the Q2 release.
0
Accepted
Vlad
Telerik team
answered on 10 Nov 2009, 07:58 AM
Hello James,

I've attached small example without PropertyRelation.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 11 Nov 2009, 06:04 AM
Hi Vlad

Thanks very much, works a treat!
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Vlad
Telerik team
James
Top achievements
Rank 1
Share this question
or