The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

[CLOSED] GridPanel DateColumn off by -4 hours

  1. #1

    [CLOSED] GridPanel DateColumn off by -4 hours

    I guess I could just add 4 hours to all datetimes, but thinking this must be some system configuration or settings that is causing this?

    <%@ Page Language="vb" %>
    
    <script runat="server">
        Private Class GridDTO
            Property ID As Integer
            Property LastPublished As Date?
            Property ChangeGuidance As String
        End Class
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack AndAlso Not Ext.Net.X.IsAjaxRequest Then
                Dim data As New List(Of GridDTO)
                Dim X = New GridDTO With {.ID = 1, .LastPublished = Now, .ChangeGuidance = ""}
                data.Add(X)
                X = New GridDTO With {.ID = 2, .LastPublished = Now, .ChangeGuidance = "Test Guidance"}
                data.Add(X)
                X = New GridDTO With {.ID = 3, .LastPublished = Now, .ChangeGuidance = ""}
                data.Add(X)
    
                storeVerification.DataSource = data
                storeVerification.DataBind()
            End If
    
        End Sub
    
        </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Edit Grid</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext2:ResourceManager ID="ResourceManager1" runat="server" />
            
                <ext2:Panel Title="Model Change Verification" runat="server" ID="pnlVerification">
                    <Items>
                       
                        <ext2:GridPanel Title="Allocation Changes" runat="server" ID="grdAllocationsVerification" AutoScroll="true">
                            <Store>
                                <ext2:Store ID="storeVerification" runat="server" >
                                    <Model>
                                        <ext2:Model runat="server" IDProperty="ID">
                                            <Fields>
                                                <ext2:ModelField Name="ID"></ext2:ModelField>
                                                <ext2:ModelField Name="LastPublished"></ext2:ModelField>
                                                <ext2:ModelField Name="ChangeGuidance"></ext2:ModelField>
                                            </Fields>
                                        </ext2:Model>
                                    </Model>
                                </ext2:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext2:Column ID="Column1" runat="server" DataIndex="ID" Hidden="true"></ext2:Column>
                                    <ext2:DateColumn Flex="1" runat="server" text="Last Published" DataIndex="LastPublished"  Format="M/d/yyyy HH:mm:ss A" ></ext2:DateColumn>
                                    <ext2:Column runat="server" DataIndex="ChangeGuidance" Text="Change Guidance" Editable="true">
                                    </ext2:Column>
                                </Columns>
                            </ColumnModel>
                        </ext2:GridPanel>
                    </Items>
     
                </ext2:Panel>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; May 16, 2017 at 6:48 PM.
  2. #2
    Hello @rmelancon!

    I've just tried your example here, but I get the actual time without any shift.

    Are you running the sample code from an IIS server, or from Visual Studio directly, with the bundled IIS Express?

    To me, the behavior you described is the same as having the server in a given time zone, and using a client with another time zone to open the page. So the server returns a time value, and the client "shifts" that to the local time zone.

    But if you are using VS's bundled IIS express and browsing on your own development machine, you should be getting the actual current date without any changes.

    Do you get the same problem using different browsers, which one have you tested with?

    This might help you diagnose it:
    - Add SourceFormatting="true" to your resource manager (makes it easier to read the page)
    - Run without debugging in VS
    - When you open the page, open the browser's developer tools
    - Open the page to see its contents (the loaded aspx file itself)
    - Look for something like that:
    proxy: {data:[{"ID":1,"LastPublished":"
    Then check if the dates are provided at that point already shifted by four hours.

    If they are already shifted at that point, code-behind's current date reads differently than your local system and that would mean either:
    - simply the server time where code behind is expanded -- the web server -- is on a different time zone
    - a setting on the website (Web.config, maybe) could be making server calls run on a different time zone

    If the dates imprinted in the source code are the expected values, whereas the client side date is displayed with the shift of hours, then we should have the client browser making the change or providing Ext.NET information so that it thinks that it is supposed to adjust the time to another time zone.

    It is hard to say anything as I can't reproduce this here, and my time zone is GMT-3, so I should be reproducing this if the problem were just being in a time zone different than GMT/UTC.

    Anyway, hope this helps you, maybe more information you provide on reproducing the issue would allow us to reproduce and provide more elaborate feedback.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @rmelancon!

    It's been a while since we last replied this inquiry and yet no feedback from you. Do you still need help with this? Without a clue to reproduce the issue on our side it is hard to help troubleshoot it.
    Fabrício Murta
    Developer & Support Expert
  4. #4
    I had to add a setting to adjust in javascript. Some globalization thing that I can't remember now what it was... but it is fixed. Thanks.
  5. #5
    Alright! Glad you could overcome the issue! Thanks for the feedback.
    Fabrício Murta
    Developer & Support Expert
  6. #6
    This is what I had to add to fix it:

    Ext.Net.JSON.GlobalSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local
    Last edited by fabricio.murta; May 18, 2017 at 9:54 PM. Reason: wrap one-line code in [var][/var] tag.
  7. #7
    Interesting, @rmelancon! Thanks for sharing the solution that worked for you!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] DateColumn format in GridPanel
    By metatronix in forum 3.x Premium Help
    Replies: 5
    Last Post: Mar 24, 2016, 4:36 PM
  2. [CLOSED] GridPanel DateColumn
    By cwolcott in forum 2.x Premium Help
    Replies: 8
    Last Post: Nov 14, 2013, 2:57 AM
  3. [CLOSED] display milliseconds in GridPanel DateColumn
    By uis_pm in forum 1.x Premium Help
    Replies: 5
    Last Post: May 28, 2012, 5:44 PM
  4. display milliseconds in GridPanel DateColumn
    By jimlahey in forum 1.x Help
    Replies: 0
    Last Post: Apr 06, 2011, 8:16 AM
  5. [CLOSED] Can a DateColumn be empty in GridPanel?
    By logicspeak in forum 1.x Premium Help
    Replies: 3
    Last Post: Oct 20, 2010, 12:49 AM

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.