We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Null data in DateTimePicker

I have seen some threads concerning the allowance of null data into a foreseen DateTimePickerEx, is there anything new on this? - Nicolas

8 Replies

VR Venkateshwaran Ramdoss Syncfusion Team July 14, 2016 08:46 AM UTC

Hi Nicolas,

Thank you for contacting Syncfusion Support.

It is possible to apply Null value to the DateTimePickedAdv by using the options below.

Option 1: By enabling IsNullDate property and also set the NullString value as empty in the DateTimePickerAdv. Refer to the below KB link.

KB link: https://www.syncfusion.com/kb/2724/how-to-set-null-value-to-datetimepickeradv  

Option  2: By creating a Custom control derived from DateTimePickerAdv and implement a property that helps to hold the Nullable value. You can refer to the below KB article.

KB link: https://www.syncfusion.com/kb/6743/how-to-assign-nullable-value-in-datetimepickeradv  

Please confirm whether the given solution works for you. Or else share us more details of the thread/forum which you had mentioned in the last update. It would be helpful to provide a prompt solution.

Regards,
Venkateshwaran V.R.



NI Nicolas July 15, 2016 03:24 AM UTC

Hi Venkateshweran, thank you for sharing this ! After implementing, the first option, it works as expected by getting or setting null values. I noticed however that this UI has sometimes a funky reaction, it might be worthwhile to take a look. Sometimes, I try to set a value and when I navigate to other controls (standard WIN textbox & combo), then I notice that either the value is not kept or it resets by itself to a null value. 

Meanwhile, I havent tried your 2nd option, but came up with a 3rd option, by the use of ComboDropDown on which I assign a MonthCalendarAdv (https://www.syncfusion.com/kb/1333/is-there-a-way-to-configure-datetimepickeradv-so-that-date-entry-is-consistent-with-the-grid-cell)

DateTImePicker1.PopupControl = MonthCalendarAdv1

DateTmePIcker1.PopupControl.Height = 150

DateTimePicker1.PopupControl.Height = 150

I like the look & feel for this 3rd option, however on this, it seems I cannot pickup the date value, and the width of the calendar seems to be dependent of the control, even if I assign it as shown previously



NI Nicolas July 15, 2016 03:28 AM UTC

Sorry you should read the code as follows:

ComboDropDown1.PopupControl = MonthCalendarAdv1

ComboDropDown1.PopupControl.Height = 150

ComboDropDown1.PopupControl.Height = 150


Thank you! - Nicolas



VR Venkateshwaran Ramdoss Syncfusion Team July 18, 2016 11:50 AM UTC

Hi Nicolas, 

Thank you for your update. 

Query 1:"PopUpControl.Height?" 

The PopUpControl Height will be specified based on control height. 

Query 2:"PopUpControl.Width?" 

We can set the PopUpControl Width by using "DropDownWidth" property. We have prepared a sample with the same and it can be downloaded from the below link. 


Code snippet: 
this.comboDropDown1.DropDownWidth = 213; 
 

Regards, 
Venkateshwaran V.R. 



NI Nicolas July 18, 2016 09:59 PM UTC

Great! Thank you! Works like a charm - Nicolas


NI Nicolas July 18, 2016 10:45 PM UTC

Hi Venkateshwaran, I have a sub-question for you : Now everything is fine, but thinking of perfecting the flow: when using the datetimepicker in the GGC, I use the GridGroupingControl1_QueryCellStyleInfo to update my form and the DateTimepickerAdv, but as you know this event is rather CPU consuming, so I tried to pass my functions through GridGroupingControl1_CurrentRecordContextChange, where it picks up the e.Action = CurrentRecordAction.BeginEdit (both), but it seems to be skipping the e.Action = CurrentRecordAction.EndEdit, is this normal? Thanks in advance - Nicolas


NI Nicolas July 19, 2016 09:41 AM UTC

Got it finally! the GridGroupingControl1_TableControlCurrentCellEditingComplete is much more efficient and does perfectly the job - Thanks again! - Nicolas


AG Anish George Syncfusion Team July 19, 2016 03:58 PM UTC

Hi Nicolas, 
  
We are glad to hear the issue has been resolved in your end. Please let us know if you need any further assistance. 
  
Regards, 
Anish 


Loader.
Live Chat Icon For mobile
Up arrow icon