I have the following namespaces in the xaml.
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
As shown in the sample code, I am not able to see CellTemplate under GridViewColumn or GridViewDataColumn. I see CellStyle, but that is not what I am looking for. What am I missing here?
I am trying to add a "Select" HyperLink column, on click of which the user will be navigated to Details screen with respective data. This is a common task, so if there is a better way (instead of using a select link column), I would love to know.
Thanks much.
Deven
5 Answers, 1 is accepted
To edit the template of the cell you can simply do the following:
| <Style x:Key="MyCellStyle" TargetType="grid:GridViewCell"> |
| <Setter Property="Template> |
| <Setter.Value> |
| <ControlTemplate TargetType="grid:GridViewCell"> |
| <!-- Place your cell template here --> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| </Style> |
| xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" |
As for the second part of your question. Please review this example for more information on how to make a hyperlink in the column.
Kind regards,
Kalin Milanov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I have implemented the CellStyle now, but I have one issue, when I have to click thrice on the hyper link for it to work. First click on the row to select it (clicking on hyper link does not select the row :o. ) and then click on hyperlink (I guess activates the cell edit mode) and then the final click on the link. Is there a way that when user clicks on link, the row is selected and the click event is fired with with correct row datacontext?
<
telerikGridView:RadGridView AutoGenerateColumns="False" IsFilteringAllowed="True" ShowGroupPanel="True"
ColumnsWidthMode="Fill" IsReadOnly="True" SelectedItem="{Binding SelectedExclusionSummary, Mode=TwoWay}"
ItemsSource="{Binding ExclusionSummaryCollection}">
<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewDataColumn HeaderText="Person Name" DataMemberPath="PersonName" />
<telerikGridView:GridViewDataColumn HeaderText="Category" DataMemberPath="CategoryDescription" />
<telerikGridView:GridViewDataColumn HeaderText="Start Date" DataMemberBinding="StartDate" />
<telerikGridView:GridViewDataColumn HeaderText="End Date" DataMemberBinding="EndDate" />
<telerikGridView:GridViewDataColumn>
<telerikGridView:GridViewDataColumn.CellStyle>
<Style TargetType="tgv:GridViewCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="tgv:GridViewCell">
<Border BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" >
<HyperlinkButton Content="Select" VerticalAlignment="Center" HorizontalAlignment="Center"
Loaded="LoadContext" Cmd:CommandManager.CommandEventName="Click"
Cmd:CommandManager.Command="{Binding SelectCommand}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerikGridView:GridViewDataColumn.CellStyle>
</telerikGridView:GridViewDataColumn>
</telerikGridView:RadGridView.Columns>
</telerikGridView:RadGridView>
CellTemplate is new property introduced in Q1 2009 SP1 - you need our latest build.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Is there a way to select the row, when the link is clicked upon?
The HyperlinkButton control eats up mouse click events, and maybe that prevents row selection. I managed to work around that by handling the HyperlinkButton Click event and selecting the row:
| private void Hyperlink_Click(object sender, RoutedEventArgs e) |
| { |
| var row = ((FrameworkElement) sender).ParentOfType<GridViewRow>(); |
| row.IsSelected = true; |
| } |
Note that the ParentOfType method is an extension method, and you will need a using clause for the Telerik.Windows.Controls namespace in your file.
Kind regards,
Hristo Deshev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
