I'm trying to show the RadDatePicker in cells by default. I know that I can use the built in editors, but I want the pickers showing by default without the user having to click into the cell. So I made a control template based on an example I saw elsewhere in this forum doing the same thing for CheckBoxes. The code I'm using is below:
(This is of course a cut down version of my full grid)
This works fine and shows the date pickers if the dates are all null. However, if the dates are non null then the no rows display at all - this includes rows that have the dates as null. I can scroll for some reason when this happens even though I don't see any rows, and I get the following information from the Output window:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.RadGridView', AncestorLevel='1''. BindingExpression:Path=UseAlternateRowStyle; DataItem=null; target element is 'GridViewRow' (Name=''); target property is 'NoTarget' (type 'Object')
I assume this is more to do with the rows not being there than related to the DatePicker not working though.
I'm using the latest release of the controls - 2009 Q2.
I've tried binding to DisplayDate as well, and this might work except that it's a DateTime rather than a DateTime? so I can't bind to it, since my dates are nullable.
Any ideas on how to make this work?
<telerik:RadGridView Name="ActiveGrid" Grid.Row="0" Style="{DynamicResource DefaultGrid}" |
ItemsSource="{Binding Path=CompletionList}" AutoGenerateColumns="False" ScrollMode="RealTime" |
DataLoadMode="Synchronous" CanUserSortColumns="False" SelectionChanged="RadGridView_SelectionChanged" |
CurrentCellChanged="ActiveGrid_CurrentCellChanged" > |
<telerik:RadGridView.Resources> |
<ControlTemplate x:Key="completionDateCellTemplate" TargetType="{x:Type telerik:GridViewCell}"> |
<telerik:RadDatePicker SelectionChanged="RadDatePicker_SelectionChanged" VerticalAlignment="Center" |
SelectedDate="{Binding Path=dtDateCompleted}"/> |
</ControlTemplate> |
<Style x:Key="completionDateCellStyle" TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="telerik:GridViewCell.Template" Value="{StaticResource completionDateCellTemplate}" /> |
</Style> |
</telerik:RadGridView.Resources> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn Width="*" Header="Comp." Name="CompDateCompleted" |
CellStyle="{StaticResource completionDateCellStyle}" TextWrapping="Wrap" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
This works fine and shows the date pickers if the dates are all null. However, if the dates are non null then the no rows display at all - this includes rows that have the dates as null. I can scroll for some reason when this happens even though I don't see any rows, and I get the following information from the Output window:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.RadGridView', AncestorLevel='1''. BindingExpression:Path=UseAlternateRowStyle; DataItem=null; target element is 'GridViewRow' (Name=''); target property is 'NoTarget' (type 'Object')
I assume this is more to do with the rows not being there than related to the DatePicker not working though.
I'm using the latest release of the controls - 2009 Q2.
I've tried binding to DisplayDate as well, and this might work except that it's a DateTime rather than a DateTime? so I can't bind to it, since my dates are nullable.
Any ideas on how to make this work?