Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
Default Date when changing from null value to a non-null value
posted

I'm using NetAdvantage version  9.1.20091.2012

I have an UltraDateTimeEditor which is data binded to a business object that exposes a property "StartTime" of type DateTime? (nullable DateTime). When the business object is created the default value of the property is null.

I'm only interested in the time part of the DateTime, so the StartTime property has to be be higher or equal than 01/01/2000 12:00:00 AM and lower or equal than 01/01/2000 11:59:00 PM. I'm setting the MinDate and MaxDate of the editor to those values.

I want the spin buttons visible, so they are enabled and the SpinIncrement is 1 minute.

In the attached sample application there are two editors with the configuration described above. The one on the top (let's call it dte1) displays Date and Time. The one on the bottom (let's call it dte2) only displays Time and that's the one I intend to use in my application.

I noticed the following behaviors:

1) When I type a time in dte2 and tab out of the control the value is not accepted and remains null. The spin buttons are enabled when I tab in. As soon as I click any of them they become disabled and the time changes 1:00 AM. If I tab out the value is discarded and remains null. That tells me the date part was not being set when the MaskInput includes time only.

Question: What's the right way to deal with the Time part only and set the Date part to a predefined value when changing from null to not-null?

2) When I tab into dte1 the spin buttons are enabled. If I click the up arrow the value changes to 01/01/2000 01:00 AM, which is a valid value.  In test 1) that doesn't happen. For dte2 the spin buttons are disabled instead. 

Is there a way to get that behavior in dte2?

3) With dte1 set to null, when I tab into dte1 and click the down spin button the time changes to 11:59 PM. That's fine because that's my MaxDateTime. Now I set dte1 to null again, tab into the control and click the up spin button. The Time changes to 1:00 AM. It should change to 12:00 AM right?

4) Right after dte1 changes to 1:00 AM in test 3), the down spin button is disabled, as if 1:00 AM was the minimum value, which is wrong. 12:00 AM is the actual minimum value, so the down arrow should be enabled until I reach 12:00 AM, not 1:00 AM.

5) I enabled SpinWrap in dte1, then click the spin up arrow. When I reach 11:59 PM it wraps to 1:00 AM. It should wrap to 12:00 AM instead.

6) If I type 12:30 AM in dte1 and click the up spin arrow it changes to 12:31 AM. That's fine. Now if I click the down arrow it changes to 1:00 AM. It should change back to 12:30 AM.

I think those are many unexpected behaviors. Maybe I'm missing something?

Any help Infragistics or other users can provide is greatly appreciated.

Thanks,

Oscar.

UltraDateTimeEditorNullableTest.zip
Parents
No Data
Reply
  • 69832
    Suggested Answer
    Offline posted

    The .NET data binding layer can't handle nullable types, so that is part of the problem. The MinDate/MaxDate settings are also causing a problem; the time components of that property are not used so the control interprets this as no date being valid .

    Also the way you have the JOJO.StartTime property declared is probably not as intended; it looks like abstract notation, with no implementations for the get or set method. The data binding layer is choking on this, so that is another part of the problem.

Children