Datefield from to range is broken

  1. #1

    Datefield from to range is broken

    http://prntscr.com/acaxhk
    SET FROM :2016-03-01 09:00:00
    SET TO : 2016-03-01 19:00:00
    WATCH WORLD BURN

    <script runat="server">  
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        [DirectMethod]
        public object DirectCheckField_m(string value)
            
        {  
            int year_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Year);
            int month_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Month);
            int day_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Day);
            int hour_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Hour);
            int minute_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Minute);
            int second_ = Convert.ToInt16(Convert.ToDateTime(DateField1.RawText).Second);
    
            DateTime chosed = new DateTime(year_, month_, day_, hour_, minute_, second_); 
            if (hour_ == 0 && minute_ == 0 && second_ == 0)
            chosed = new DateTime(year_, month_, day_, 08, minute_, second_); 
            DateField1.Value = chosed.ToString();
    
            d_mont.Value = DateField1.Value;
           //DateField1.ValidateOnChange=false;
            return true;
        }
        [DirectMethod]
        public object DirectCheckField_d(string value)
        {  
            int year_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Year);
            int month_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Month);
            int day_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Day);
            int hour_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Hour);
            int minute_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Minute);
            int second_ = Convert.ToInt16(Convert.ToDateTime(DateField2.RawText).Second);
            
            DateTime chosed = new DateTime(year_, month_, day_, hour_, minute_, second_);
            if(hour_==0 && minute_==0 &&second_==0)
            chosed = new DateTime(year_, month_, day_, 20, minute_, second_);
            DateField2.Value = chosed.ToString(); 
            d_mont.Value = DateField2.Value;
            return true;
        }
        
        
    </script>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Novo dia 2</title>
         
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Window runat="server" Layout="FitLayout" Width="600">
                <Items>
                    <ext:FormPanel ID="top_1" runat="server" Title="Detalhes" Header="false" Frame="true" Border="false" Layout="ColumnLayout" BodyPadding="10" DefaultAnchor="100%">
                        <Items>
                            <ext:Panel ID="top_left" runat="server" ColumnWidth="0.5" Border="false" Header="false" Layout="VBoxLayout" LabelAlign="Top">
                                <Items>
                                    <ext:DateField ID="DateField1" runat="server" Type="Date"  StandardVtype="DateRange"  FieldLabel="InÃ*cio" Format="yyyy-MM-dd HH:mm:ss" IsRemoteValidation="true"  >
                                        <RemoteValidation DirectFn="App.direct.DirectCheckField_m" />
                                        <CustomConfig>
                                            <ext:ConfigItem Name="endDateField" Value="DateField2" Mode="Value" />  
                   
                                        </CustomConfig>
                                    </ext:DateField>
                                    <ext:DateField ID="DateField2" runat="server" Type="Date" StandardVtype="DateRange"   FieldLabel="Fim" Format="yyyy-MM-dd HH:mm:ss"> 
                                        <RemoteValidation DirectFn="App.direct.DirectCheckField_d" />
                                        <CustomConfig>
                                            <ext:ConfigItem Name="startDateField" Value="DateField1" Mode="Value" />  
                    
                                        </CustomConfig>
                                    </ext:DateField>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="top_right" runat="server" ColumnWidth="0.5" Border="false" Header="false" Layout="VBoxLayout" LabelAlign="Top">
                                <Items>
                                    <ext:DateField ID="d_mont" runat="server" FieldLabel="Montagem" Editable="true" Format="yyyy-MM-dd HH:mm:ss">
                                    </ext:DateField>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
  2. #2
    Hello @dim4ik2008!

    I'm sorry to hear you are having hard times with Ext.NET date fields and validation!..

    Actually, something that happens is that we have two separate date -and- time fields. But there is not a "DateTimeField". So you have to deal with those parts of the field sepparately is not really going to work 100%. But as you are forcing a specific time for each field, you should be good.

    Here's an explanation on why you can't get the current value of DateField1 & DateField2 during the direct methods the way you are doing it: Hidden controls not responding to direct event actions.

    It also gives ways to effectively access the values.

    That said, you'll need to use a hybrid implementation with local & remote validation. Actually a local, javaScript validation that passes both compared fields' values to a direct method which then you can get the result from (assynchronously, via the success: callback -- more about it on this example).

    Only then you would be able to get proper validation to this DateField usage. You may also want to include TimeField fields on your form in order to better handle the time of the day (should you want the user to choose custom times).

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    First of all
    thank you for taking time and replying

    issue is not in my code,

    issue is that StandardVtype="DateRange" and Vtype="DateRange" are not testing hours, minutes and seconds.
    pick
    From 2016-03-18 09:00:00<-
    End 2016-03-18 20:00:00
    and is marked as invalid for From
    pick
    From 2016-03-18 00:00:00<-
    End 2016-03-18 20:00:00
    and is marked as valid
  4. #4
    Hello @dim4ik2008!

    DateField does not consider the time bits on the stored date. For that you have TimeField. It is really a feature missing, a combined component for Date and time at the same place.

    But you can customize your validation to compare that as well. I believe this example gives good leads on how to make it: Custom VType.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    But you can customize your validation to compare that as well. I believe this example gives good leads on how to make it: Custom VType.
    could you please provide example of date and time mixed validation vtype. i am bit limited in this stuff
  6. #6

    any update?

    any update? on date+time vtype?
  7. #7

    None wants to help me with this

    Explanation of solution was given, so it should be marked as Closed
    but no solution for problem given. should this be open for submit of solution or closed?

Similar Threads

  1. [CLOSED] Datefield Custom Range
    By blueworld in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 30, 2014, 5:32 PM
  2. [CLOSED] Clean the previously range selected from "Ext: DateField"
    By opendat2000 in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 25, 2014, 11:00 AM
  3. [CLOSED] DateField range with MasterPage
    By kevinhwang in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 28, 2013, 3:14 PM
  4. [CLOSED] DateField - From To Range
    By thchuong in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 08, 2012, 9:17 AM
  5. [CLOSED] From to date range
    By Raynald_Fontaine in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 30, 2012, 9:52 AM

Tags for this Thread

Posting Permissions