I created custom RadDataFilter , which contains dropdown list. DropDown List is OK. Now here is new requirement, I want to add telerik DateTimePicker. DateTimePicker Bind successfully, problem is that I can’t get selected date value. Therefore FilterDesripter.value is not set.
For Combobox here is template
<DataTemplate x:Key="ComboBoxEditor">
<telerik:RadComboBox SelectedValue="{Binding Value, Mode=TwoWay, FallbackValue=null}" MinWidth="100" />
</DataTemplate>
But how I’ll set selectedDate Value, here is my Code.
<DataTemplate x:Key="DateTimeEditor">
< telerik:DatePicker MinWidth="100" SelectedDate="{Binding Value}"></my:DatePicker>
</DataTemplate>
9 Answers, 1 is accepted
Could you try setting the Mode to TwoWay? I believe that this should solve the problem.
It should look something like this:
<
telerik:RadDatePicker
SelectedValue
=
"{Binding Value, Mode=TwoWay}"
/>
Nikolay Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
<
UserControl.Resources
>
<
DataTemplate
x:Key
=
"DateTimeEditor"
>
<
telerik:RadDateTimePicker
SelectedDate
=
"{Binding Value, Mode=TwoWay}"
MinWidth
=
"100"
/>
</
DataTemplate
>
<
local:ListPanelEditorTemplateSelector
x:Key
=
"EditorTemplateSelector"
>
<
local:ListPanelEditorTemplateSelector.EditorTemplateRules
>
<
local:ListPanelEditorTemplateRule
PropertyName
=
"Time"
DataTemplate
=
"{StaticResource DateTimeEditor}"
/>
</
local:ListPanelEditorTemplateSelector.EditorTemplateRules
>
</
local:ListPanelEditorTemplateSelector
>
</
UserControl.Resources
>
.
.
.
<
telerik:RadDataFilter
Name
=
"myGridDataFilter"
EditorTemplateSelector
=
"{StaticResource EditorTemplateSelector}"
EditorCreated
=
"myGridDataFilter_EditorCreated"
MinHeight
=
"20"
Width
=
"auto"
FilterOperatorsLoading
=
"myGridDataFilter_FilterOperatorsLoading"
Source
=
"{Binding myData}"
BorderThickness
=
"10"
Margin
=
"0,0,0,0"
/>
.
.
.
<
telerik:RadGridView
...
ItemsSource
=
"{Binding FilteredSource, ElementName=myGridDataFilter, IsAsync=True, Mode=OneWay}"
><
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Time"
Name
=
"Time"
Width
=
"120"
DataMemberBinding
=
"{Binding Time}"
IsGroupable
=
"True"
IsFilteringDeferred
=
"True"
ShowDistinctFilters
=
"True"
IsFilterable
=
"False"
/>
<
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
How do I get the RadDateTimePicker to filter my RadGridView data?
I can suggest you to check our online Demo. There is an example with RadDateTimePicker as RadDataFilter's editor.
I hope this helps.
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Indeed, you are quite right. In the link provided there is no DateTimePicker template defined. Please excuse me for this.
However, I have prepared a sample project for you, based on this help article. It shows you how to define a RadDateTimePicker as a custom filter editor. Please find it attached.
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Indeed, the built-in filter editors are created at run-time based on the property type. For strings, the default editor is a TextBox, for boolean it is a CheckBox and for dates it is a RadDateTimePicker. Please check this help article for more information.
If you want to reconfigure the RadDateTimePicker, you can handle DataFilter's EditorCreated event as I showed you in the provided sample project.
May I ask you what exactly you are trying to achieve?
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
<
DataTemplate
>
<
telerik:RadDateTimePicker
Style
=
"{StaticResource myStyle}"
InputMode
=
"DatePicker"
SelectedValue
=
"{Binding Value, Mode=TwoWay}"
MinWidth
=
"100"
/>
</
DataTemplate
>
All the other posts in this thread have the same case. They are also defining custom template for DateTimePicker. So, can you please create a working demo where you can reconfigure the DateTimePicker.
My colleague explained this in his post, but let me try to explain it once more.
1. You don't need to define a custom editor template in you case. This technique is only used when you want to supply a custom editor which is not among the default ones, which is not the case here. We already can produce a date picker for you.
2. You only want to modify our stock RadDateTimePicker. This is done very simply. Attach to the EditorCreated event, check whether the editor is a RadDateTimePicker and if it is -- set its properties as you like. That''s it.
You either use approach 1 or approach 2 but there is no sense in using both at the same time. In your case you should use approach 2.
So to summarize:
1. No need for a custom editor DataTemplate.
2. Configure the RadDateTimePicker that we create in the RadDataFilter.EditorCreated event handler.
I hope that this makes sense.
All the best,
Rossen Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.