Declined
Last Updated: 22 May 2020 11:41 by ADMIN
Ryan
Created on: 21 May 2020 17:44
Category: DateTimePicker
Type: Feature Request
0
Button to clear the values selected in the control
I see there is a clear event but there isn't a button built on the control to allow the user to clear the selected values.  This would allow for the control to be used as a nullable date time. 
1 comment
ADMIN
Didi
Posted on: 22 May 2020 09:26

Hi Ryan,

Thank you for your input.

I have changed the item status to "Declined" as we think this is not a valid feature request for the default look of the DateTimePicker control. 

If you want to customize the default look of the control you can use the provided templates. In order to add a clear button inside the picket's popup footer, you can use the FooterTemplate. Example:

DateTimePicker definition:

<telerikInput:RadDateTimePicker Date="{Binding Value}" x:Name="picker">
    <telerikInput:RadDateTimePicker.SelectorSettings>
        <telerikInput:PickerPopupSelectorSettings FooterTemplate="{StaticResource PickerFooterTemplate}" />
    </telerikInput:RadDateTimePicker.SelectorSettings>
</telerikInput:RadDateTimePicker>

 

In order to clear the selection you can use one of the following approaches:

1) ClearSelection method - the footer template definition and additional clear button

<ControlTemplate x:Key="PickerFooterTemplate">
    <StackLayout Orientation="Horizontal"
                    Spacing="0"
                    HorizontalOptions="FillAndExpand">
        <Button Text="Clear"
                BackgroundColor="Transparent"
                Clicked="Button_Clicked"/>

        <Button Text="{TemplateBinding AcceptButtonText}"
                    BackgroundColor="Transparent"
                    Command="{TemplateBinding AcceptCommand}" />
        <Button Text="{TemplateBinding CancelButtonText}"
                BackgroundColor="Transparent"
                Command="{TemplateBinding CancelCommand}" />
    </StackLayout>
</ControlTemplate>

call clearselection method inside the button click event.

private void Button_Clicked(object sender, EventArgs e)
{
    this.picker.ClearSelection();
}

2) Clear Command - footer template definition:

<ControlTemplate x:Key="PickerFooterTemplate">
    <StackLayout Orientation="Horizontal"
                    Spacing="0"
                    HorizontalOptions="FillAndExpand">
        <Button Text="Clear"
                BackgroundColor="Transparent"
                Command="{Binding Source={x:Reference picker}, Path=ClearCommand}"/>

        <Button Text="{TemplateBinding AcceptButtonText}"
                    BackgroundColor="Transparent"
                    Command="{TemplateBinding AcceptCommand}" />
        <Button Text="{TemplateBinding CancelButtonText}"
                BackgroundColor="Transparent"
                Command="{TemplateBinding CancelCommand}" />
    </StackLayout>
</ControlTemplate>


Nullable DateTime

Regarding the "nullable date time", this scenario could be achieved using DateTimePicker.Date property. The date property is of type DateTime? and its default value is null. For more information please check the Selection article from our documentation.

Regards,
Didi
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.