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

Set date to null

3 Answers 64 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 09 Oct 2017, 07:33 AM

Hi,

Is it possible to set the date to empty from the ui?

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 12 Oct 2017, 06:47 AM
Hello John,

With its current implementation the DatePicker control does not provide any UI for setting the date value to null. What you could do is either to create some external UI from where you can set the Value to null or you can modify the default template of the control and place in it a control (button for example) that could provide you the ability for setting the desired value.

We hope the provided information will be helpful for you.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Robert
Top achievements
Rank 1
answered on 28 Mar 2019, 06:29 PM
I would like to be able to set the datepicker value to null also. I would like to do this within the DatePicker in the radDataGrid.   Do you have an example of your second suggestion where we modify the template?
0
Lance | Manager Technical Support
Telerik team
answered on 28 Mar 2019, 06:50 PM
Hi John,

It would be more simple to put a "clear" button next to the Date/TimePicker and use that to set the backing DateTime object's value to null (this is what you would be doing inside the ControlTemplate anyways, but you wouldn't run the risk of breaking the control by changing its internal components).

That being said, if you do want to change the ControlTemplate, you can follow these instructions on how to use Visual Studio or Blend to extract the Template of a UIElement that has an extractable style for customization.

Note: Although the documentation link is to our WPF documentation, it's same procedure to extract any XAML element's Style (not just a Telerik control). If you have trouble with the context menu in the designer surface, you can get the same context menu by right clicking on the DatePicker control in the Document Outline pane.

Once you've extracted the Style, then look for the Template property of the Style, this will contains a ControlTemplate setter. That ControlTemplate is what defines the structure of the control. You can put your custom clear button in there. One word of caution, do not delete anything with the "PART_" prefix in the name, these are required parts of the template.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

Tags
DatePicker
Asked by
John
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Robert
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or