Need to use DateTimeEditor with empty date enabled in property grid

I have a date field that can be null. I don't want to show 1/1/0001 as the default date.
Default widget for DateTime property is DateTimeEditor without the No date option.
Default for DateTime? type is just a text box.

How can I connect a nullable DateTime property with a DateTimeEditor having IsEmptyDateEnabled = true ?

5 Replies

GS Gokul Sainarayanan Syncfusion Team July 11, 2018 12:48 PM UTC

Hi Steve,

We have checked your reported query and it can be achieved by using the Custom Editor in the PropertyGrid. In order to display the null value in the DateTimeEdit, we need to set the properties IsEmptyDateEnabled, NoneDateText, ShowMaskOnNullValue and the type of DateTime should be nullable. We have prepared a sample for the same and it can be downloaded from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/138632/ze/PropertyGridCustomEditor_DateTimeEdit2071708992

Please check with the above sample and let us know whether it meets your requirement.

Regards,
Gokul S


SM Steve McWilliams July 11, 2018 03:33 PM UTC

Thanks. I got this to work for the DateTime properties.

I also realized I need to do the same thing for some nullable int properties.
I followed the DateTime example to try and add a custom editor using IntegerTextBoxEditor for int? property type.
I got as far as getting the box to allow null values, but it's not accepting and storing actual values.

Could you send me an example of similar code I need to construct IntegerTextBox Editor with UseNullOption = true ?



GS Gokul Sainarayanan Syncfusion Team July 12, 2018 07:01 AM UTC

Hi Steve,

Thanks for your update.

In IntegerTextBox, we have maintained Int64? Type for the Value property and since you have set the property as int? type, the value was not updated properly in the sample. We have now modified the sample by adding a CustomEditor for the IntegerTextBox and have set the type as Int64?. Please download the modified sample from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/138632/ze/PropertyGridCustomEditor_IntegerTextBox397866528

Please check with the above sample and let us know whether it meets your requirement.

Regards,
Gokul S


SM Steve McWilliams July 12, 2018 02:10 PM UTC

Thanks. Changing to Int64 did the trick


GS Gokul Sainarayanan Syncfusion Team July 13, 2018 05:05 AM UTC

Hi Steve,

Thanks for your update.

Please let us know if you have any further queries.

Regards,
Gokul S

Loader.
Up arrow icon