Create custom RadDataFilter DateTimePicker

10 posts, 1 answers
  1. Kamran
    Kamran avatar
    16 posts
    Member since:
    Nov 2011

    Posted 24 Nov 2011 Link to this post

    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>

  2. Answer
    Nick
    Admin
    Nick avatar
    593 posts

    Posted 24 Nov 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Nathan
    Nathan avatar
    1 posts
    Member since:
    Dec 2012

    Posted 20 Dec 2012 Link to this post

    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?

  5. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 21 Dec 2012 Link to this post

    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.

  6. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 08 Feb 2013 Link to this post

    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
  7. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 12 Feb 2013 Link to this post

    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.

  8. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 22 Feb 2013 Link to this post

    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.
  9. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 26 Feb 2013 Link to this post

    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.

  10. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 26 Feb 2013 Link to this post

    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.
  11. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 27 Feb 2013 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready