How To define child columns

2 posts, 1 answers
  1. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 30 Jun 2008 Link to this post

    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
  2. Answer
    Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 02 Jul 2008 Link to this post

    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
Back to Top