I have a GridView which is grouped based on a certain criteria. In the group row, I want to display the name (which is getting displayed) and a image which when clicked should perform a certain task. The image should also be of toggle type, which means on a certain condition I should display Active image and on certain condition I should display Inactive image.
I am able to display the image and text on the group row using Control Template, but neither am I able to add an event to the image, nor the toggle effect is showing up.
Can anyone help me in this regard?
The attached image will tell you what I want to do. The images should be displayed based on a certain condition and only one of them should display. Besides, it should be properly positioned.
Thanx,
Subrajit
12 Answers, 1 is accepted
Why not try with a GroupHeaderTemplateSelector instead?
Vanya Pavlova
the Telerik team
I strongly suggest you to check the demo code and let us know if you have any specific questions related to our implementation.
All the best,Vlad
the Telerik team
The approach will work no matter how you get your data - from data-base or memory.
Greetings,Vlad
the Telerik team
This is my code snippet. The controls are not getting the data that is being retrieved from the database.
<
telerik:RadGridView.GroupHeaderTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<!--<TextBlock Text="{Binding .,Converter={StaticResource gp}}"/>-->
<!--<TextBlock Text="This is it"/>-->
<
TextBlock
x:Name
=
"txtName"
Text
=
"{Binding Name}"
></
TextBlock
>
<
Button
x:Name
=
"btnFlagYes"
Style
=
"{StaticResource btnStyle}"
Visibility
=
"{Binding Flag, Converter={StaticResource ShowFlag}, ConverterParameter=false}"
ToolTipService.ToolTip
=
"Flag"
Tag
=
"{Binding}"
Click
=
"btnFlag_Click"
/>
<
Button
x:Name
=
"btnFlagNo"
Visibility
=
"{Binding Flag, Converter={StaticResource ShowFlag}, ConverterParameter=false}"
Style
=
"{StaticResource btnStyleSmall}"
ToolTipService.ToolTip
=
"Flag"
Tag
=
"{Binding}"
Click
=
"btnFlagNo_Click"
/>
</
StackPanel
>
</
DataTemplate
>
</
telerik:RadGridView.GroupHeaderTemplate
>
The DataContext here is not a data item but grid group view model. You can check also this demo to know more how to access various properties.
Kind regards,Vlad
the Telerik team
I'm not sure if I understand your question. Have you checked the code of both demos? Do you know what is DataContext?
All the best,Vlad
the Telerik team
Indeed that is why we've suggested you to use GroupHeaderTemplateSelector where you can return unlimited number of templates according to your scenario. To access columns data in case of grouping you should access Group.Items.
Regards,Vlad
the Telerik team