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

How To define child columns

1 Answer 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 30 Jun 2008, 12:51 PM
Hi,

I have a grid that i declare in xaml but i want to define the child columns of the hierarchy (not autogenarated).

How can you do that?

My code:
Defining the child relation  
GridViewTableDefinition detailDefinition = new GridViewTableDefinition();  
detailDefinition.Relation = new PropertyRelation("QueueItemActions");  
radGridResubmit.TableDefinition.ChildTableDefinitions.Add(detailDefinition);  
 
 
Grid declaration  
       <Telerik:RadGridView HorizontalAlignment="Stretch" Width="Auto" Grid.Column="0" Grid.ColumnSpan="3" x:Name="radGridResubmit" AutoGenerateColumns="False">  
                <Telerik:RadGridView.Columns> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="" UniqueName="IsSelectedForResubmit" > 
                        <Telerik:GridViewColumn.CellStyle> 
                            <Style TargetType="{x:Type Telerik:GridViewCell}">  
                                <Setter Property="Template" Value="{StaticResource CheckBoxColumnTemplate}"/>  
                            </Style> 
                        </Telerik:GridViewColumn.CellStyle> 
                    </Telerik:GridViewDataColumn> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="JobId" UniqueName="JobId" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ConfiguredBy" UniqueName="ConfiguredBy" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="BuildLocal" UniqueName="BuildLocal" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="Copies" UniqueName="Copies" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ParentId" UniqueName="ParentId" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="StatusId" UniqueName="Status.Description" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="QueueItemId" UniqueName="QueueItemId" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ImportId" UniqueName="ImportId" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="QueueDescription" UniqueName="Queue.Description" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="QueueEnvironment" UniqueName="Environment" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="PrinterTray" UniqueName="PrinterTray.Description" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="Printer" UniqueName="PrinterTray.Printer.Name" /> 
                    <Telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ReportService" UniqueName="PrinterTray.Printer.ReportService.Name" /> 
                </Telerik:RadGridView.Columns> 
                  
            </Telerik:RadGridView> 

Regards

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo Deshev
Telerik team
answered on 02 Jul 2008, 01:42 PM
Hi NS,

I am not sure if you can do this from XAML (yet!), but you can define your columns in your code-behind. The idea is to add columns to the TableDefinition FieldDescriptors collection. Here is a sample:

GridViewTableDefinition definition = new GridViewTableDefinition();
definition.AutoGenerateFieldDescriptors = false;

GridViewDataColumn order = new GridViewDataColumn();
order.UniqueName = "ChildName";
order.HeaderText = "ChildName";

PropertyRelation relation = new PropertyRelation("Children");
definition.Relation = relation;

definition.FieldDescriptors.Add(order);

RadGridView1.TableDefinition.ChildTableDefinitions.Add(definition);


I am attaching a sample project that uses .NET objects with nested collections to define a hierarchy with custom columns.

Regards,
Hristo Deshev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
NS
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
Share this question
or