Clear value of date picker after it has been selected

Hi, 

I am using a DataForm which has a date picker, I was wondering how could I implement an option to clear the value of the data item after the date has been selected. The date is optional so I need to allow the user to clear if it if they have selected a date by mistake.

Thanks

Greg

1 Reply

KA Karthikraja Arumugam Syncfusion Team February 17, 2020 09:06 AM UTC

Hi Gregory, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your requirement of “clearing date picker value after selection”. As per date picker implementation, which is a picker item and on focus the editor it will show the picker so the value cannot be cleared by editing but you can explicitly clear the value by set null value to the property using DataObject property of DataForm. For instance, after a date has been selected, in a button click you can set null value and update the date editor. 
 
Please refer the following code example for binding appointments from code behind, 
private void Button_Click(object sender, System.EventArgs e) 
            (dataForm.DataObject as Contacts).Date = null
            dataForm.UpdateEditor("Date"); 
 
 
 
 Note: After set the value to property need to call UpdateEditor method to update the value in view. 
 
We have prepared a sample for the same, 
 
We hope this helps, please let us know if you have any concerns. 
 
Regards, 
Karthik Raja 


Loader.
Up arrow icon