Error in grid with date column

the grid is throwing an object reference error when you use a non-nullable DateTime property and you click the clear button in the datepicker.  I've attached a project that recreates the issue.  To recreate, bring the row into edit mode, go to the date column and click the "x", the object reference error will appear.  If you change the OrderDate column back to DateTime?, the problem goes away.

Attachment: BlazorAppValidation_fd30a354.zip

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team August 4, 2020 10:19 AM UTC

Hi Susan, 

Greetings from Syncfusion support. 

We would like to inform you that, if you require to clear the DatePicker value (i.e) setting value as null, then it is a must to specify nullable type(DateTime?) for the date value column in Grid. This is the component intended behavior.  

In case, if you need the column type as DateTime and it cannot be changed, then it is suggested to remove the clear button in DatePicker by setting ShowClearButton as false in Grid’s EditorSettings. So that, null value could not be set to SfDatePicker component.  

You can remove the clear button in SfDatePicker render in Grid edit form by using the codes below, 

 
<GridColumn Field=@nameof(Order.OrderDate) ... EditorSettings="@DateEditParams" ... EditType="EditType.DatePickerEdit" Format="d" ...></GridColumn> 
 
public IEditorSettings DateEditParams = new DateEditCellParams{    Params = new DatePickerModel() { ShowClearButton = false }};

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon