I have RowDetailsTemplate in RadGridView
<telerikGrid:RadGridView.RowDetailsTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTemplate>
</telerikGrid:RadGridView.RowDetailsTemplate>
How can I show Header for that column.
Please give solution.
Thanks,
Mahendra
10 Answers, 1 is accepted
I am not quite sure what do you mean by "Header for that column"? May you please elaborate a little bit more about your extact settings? Do you want to create some custom text which will acts as a header witin RowDetailstemplate or maybe I am missing something? If that is the case you may create your custom layout that corresponds to your needs within the defined DataTemplate.
Vanya Pavlova
the Telerik team

Yes I want to create some custom text which will acts as a header witin RowDetailstemplate.
Please give custom template code for that.
Thanks,
Mahendra
You may use the following DataTemplate with a static Text which will serve as a header:
<
DataTemplate
x:Key
=
"rowDetailsTemplate"
>
<
Grid
Background
=
"Red"
Height
=
"100"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
TextBlock
FontWeight
=
"Black"
FontSize
=
"18"
HorizontalAlignment
=
"Center"
Text
=
"Header in RowDetailsTemplate"
/>
<
StackPanel
>
<
TextBlock
Text
=
"{Binding EmployeeName}"
/>
<
TextBlock
Text
=
"{Binding CompanyName}"
/>
<
TextBlock
Text
=
"{Binding Email}"
/>
</
StackPanel
>
</
Grid
>
</
DataTemplate
>
Vanya Pavlova
the Telerik team

I used your code in my template like below
<telerikGrid:RadGridView.RowDetailsTemplate>
<DataTemplate>
<Grid Background="Red" Height="100">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock FontWeight="Black" FontSize="18" HorizontalAlignment="Center" Text="Header in RowDetailsTemplate"/>
<StackPanel Height="30" Margin="10,0,0,0" Orientation="Horizontal" Width="100" HorizontalAlignment="Left" Tag="{Binding UserID}">
<StackPanel Width="20"></StackPanel>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
</telerikGrid:RadGridView.RowDetailsTemplate>
But it doesnt display any headerin the line that other columns header are displayed.
When I click on expand button to expand then I got the below error
Error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, Type componentType)
I have tried to reproduce such a behavior but I was not able to. May you please try to isolate the problem in a runnable project and send it to us in a new support ticket where we can see what might be wrong?
Thus we would be able to provide you with an appropriate solution.
Vanya Pavlova
the Telerik team

Your code works fine, it displays Header after expand .
But i want to display header for Gridview on top side in the same line where other normal columns header get displayed. Means as Gridview displayed want to show header for first column, not after expanding item
Thanks,
Mahendra
I am not quite sure that I understand your requirement correctly. May you please share with us some additional info about the desired final result? The Header property of each GridViewColumn is of type object and you may predefine in thw way you need, the mechanism is described in our online documentation.
However I am not quite sure how this is related to the RowDetails or maybe I am missing something?
Vanya Pavlova
the Telerik team

Please find attached image, where i explain where do i need that header.
Thanks,
Mahendra
Thank you for sharing this picture to us! Actually you are trying to place a header in a GridViewToggleRowDetailsColumn. You may do this in the same way as you can for any column, please refer to the following:
<
telerik:GridViewToggleRowDetailsColumn
Header
=
"RowDetailsHeader"
/>
Regards,
Vanya Pavlova
the Telerik team

Thank you very much.......It works perfectly.
Mahendra