This is a migrated thread and some comments may be shown as answers.

Create custom RadDataFilter DateTimePicker

9 Answers 156 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Kamran asked on 24 Nov 2011, 01:50 PM

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

Sort by
0
Accepted
Nick
Telerik team
answered on 24 Nov 2011, 02:56 PM
Hello Kamran,

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}"/>
Best wishes,
Nikolay Vasilev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nathan
Top achievements
Rank 1
answered on 20 Dec 2012, 11:14 PM
I have a RadDataFilter with a DateTimePicker displaying correctly, but it does not filter my RadGridView.
<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?

0
Yoan
Telerik team
answered on 21 Dec 2012, 02:29 PM
Hello Nathan,

I can suggest you to check our online Demo. There is an example with RadDateTimePicker as RadDataFilter's editor.

I hope this helps.

Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yezdi
Top achievements
Rank 1
answered on 08 Feb 2013, 04:59 PM
I do not see a datetimepicker template in the template rule collection while looking in the xaml of the demo. Am i missing something here
0
Yoan
Telerik team
answered on 12 Feb 2013, 04:58 PM
Hi Yezdi,

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.

Kind regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yezdi
Top achievements
Rank 1
answered on 22 Feb 2013, 04:52 PM
I still do not see a DatePicker template anywhere in the sample project attached. It is the exact replica of the link which you have provided and that also does not have the template.
0
Yoan
Telerik team
answered on 26 Feb 2013, 12:52 PM
Hi Yezdi,

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?


All the best,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yezdi
Top achievements
Rank 1
answered on 26 Feb 2013, 06:15 PM
As you mentioned , i am using the EditorCreated event fired by RadDataFilter and create the RadDateTimePicker. The RadDateTimePicker is declared in the DataFilterEditorTemplateSelector as per the example and the DateTimePicker appears as expected in the UI, but when i select a date from teh picker , the selected date is not gettiing set in the associated textbox and also the FilterDescriptor is also "<Unset>". I have two way binding set for my DateTimePicker.

 

<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.
0
Rossen Hristov
Telerik team
answered on 27 Feb 2013, 09:09 AM
Hello,

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.

Tags
DataFilter
Asked by
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Nick
Telerik team
Nathan
Top achievements
Rank 1
Yoan
Telerik team
Yezdi
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or