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

[Solved] CellTemplate for ChildTable

9 Answers 141 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.
Martin
Top achievements
Rank 1
Martin asked on 24 Sep 2010, 11:09 AM

Hi,

I would like to have a cell template for the ChildTable to display the color like in the "main" table.

How can I archive this?

Thanks,

Martin

Here is my code:

<telerik:RadGridView.ChildTableDefinitions>
               <telerik:GridViewTableDefinition>
                    <telerik:GridViewTableDefinition.Relation>
                        <telerik:PropertyRelation ParentPropertyName="Relation"/>
                    </telerik:GridViewTableDefinition.Relation>
                </telerik:GridViewTableDefinition>
            </telerik:RadGridView.ChildTableDefinitions>
         <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Color" DataMemberBinding="{Binding Color}">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Border Width="30" Height="20" Background="{Binding Color}"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                       <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}">
                </telerik:GridViewDataColumn>
                 </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

 

 

 

9 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 24 Sep 2010, 01:22 PM
Hello Martin,

You can define a CellTemplate for child tables using Custom Hierachy Template.
If you need any further assistance, please let me know.


All the best,
Vanya Pavlova
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
0
Martin
Top achievements
Rank 1
answered on 24 Sep 2010, 01:53 PM
Thank you - that helped me alot.

But I have another question. When I select a Item in the ChildTable - how can I get the SelectedItem?
If I use radGridview.SelectedItem I get "null".

Thanks,

Martin
0
Vanya Pavlova
Telerik team
answered on 24 Sep 2010, 03:30 PM
Hello Martin,

As you defined a HierachyChildTemplate,  you can use the RowLoaded event to access rows in child grids-please use the following forum thread for a reference.


Greetings,
Vanya Pavlova
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
0
Martin
Top achievements
Rank 1
answered on 24 Sep 2010, 03:48 PM
Hello Vanya,

thanks for your answer. That does not help me getting the SelectedItem from the ChildRow. I need the Selected Item of the Child Row when it's selected by the costumer.

Thanks,

Martin
0
Veselin Vasilev
Telerik team
answered on 28 Sep 2010, 02:37 PM
Hi Martin,

You can use the SelectionChanged event of the child gridview to get the selected item. You can store it in a variable and use it later when you need it.


Best wishes,
Veselin Vasilev
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
0
Martin
Top achievements
Rank 1
answered on 29 Sep 2010, 07:32 AM
I tried it. But sometimes I get no result. Do you have any examples?
0
Vanya Pavlova
Telerik team
answered on 29 Sep 2010, 10:23 AM
Hello Martin,

You may use the following code:
private void childGrid_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
{
     var item = this.childGrid.SelectedItem as MyObject;
     MessageBox.Show(item.ID.ToString());
}


Regards,
Vanya Pavlova
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
0
Martin
Top achievements
Rank 1
answered on 29 Sep 2010, 10:57 AM
That does not work either - for some childGrids I don't get the selected item, its "null".

Is this a bug ?
0
Vanya Pavlova
Telerik team
answered on 30 Sep 2010, 09:27 AM
Hi Martin,

Everything works fine on my side, please submit a support ticket and send us a small application that reproduces this behavior, because obviously there is something specific in your scenario.
 
Greetings,
Vanya Pavlova
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
Martin
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Martin
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or