[CLOSED] [1.0] jsonStore.loadData(json) is not changing date string into object inside IE 8

  1. #1

    [CLOSED] [1.0] jsonStore.loadData(json) is not changing date string into object inside IE 8

    hi,

    please fix this bug in the bad IE 8

    createJsonStoreFromJsonResults = function(json) {
        /* prepare results for reader */
        var flds = [];
        $.each(json, function(n, v) {
            var recordField = { 'name': n }
            if (n != undefined && (n + "").toLowerCase().indexOf('date') > -1) {
                recordField['type'] = 'date';
            }
            flds.push(recordField);
        });
        /* process results and convert them to bindable format */
        var store = new Ext.data.JsonStore({
            idProperty: flds[0].name,
            fields: flds
        });
        /* load json data into store */
        store.loadData(json,true);
        return store;
    }
    the above js function work fine in firefox but not in the IE... please test it and fix it.

    bye and thanks,
    Last edited by Daniil; Nov 08, 2010 at 7:13 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please provide full test sample and describe the problem in details
  3. #3
    Vladimir... this what you asked for!!

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
    
        <script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script>
    
        <script runat="server">
            [DirectMethod]
            public static DataTable GetScheduleInformation(long schNo)
            {
                DataTable table = new DataTable();
                table.Columns.Add("proposalDate", typeof(DateTime));
                table.Rows.Add(DateTime.Now);
                return table;
    
            }
            
        </script>
    
        <script type="text/javascript">
            createJsonStoreFromJsonResults = function(json) {
                /* prepare results for reader */
                var flds = [];
                $.each(json, function(n, v) {
                    var recordField = { 'name': n }
                    if (n != undefined && (n + "").toLowerCase().indexOf('date') > -1) {
                        recordField['type'] = 'date';
                    }
                    flds.push(recordField);
                });
                /* process results and convert them to bindable format */
                var store = new Ext.data.JsonStore({
                    idProperty: flds[0].name,
                    fields: flds
                });
                /* load json data into store */
                store.loadData(json, true);
                return store;
            }
    
            loadFormControls = function(sId) {
    
                Ext.net.DirectMethods.GetScheduleInformation(sId,
                 {
                     success: function(result) {
                         if (result[0].json == undefined) {
                             result[0] = createJsonStoreFromJsonResults(result[0]).getRange(0, 0)[0];
                         }
                         Ext.getCmp('fp1').getForm().loadRecord(result[0]);
                     },
                     failure: function(result) {
                         alert(result);
                     }
                 });
            }
        </script>
    
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:FormPanel runat="server" ID="fp1">
            <Items>
                <ext:Button runat="server" ID="btnLoad" Text="Bind">
                    <Listeners>
                        <Click Handler="loadFormControls(5);" />
                    </Listeners>
                </ext:Button>
                <ext:DateField runat="server" ID="dtProposalDate" FieldLabel="Proposal Date" DataIndex="proposalDate"
                    AnchorHorizontal="95%" Disabled="true" Format="dd/MM/yyyy" />
            </Items>
        </ext:FormPanel>
    </body>
    </html>
    the above code work fine on FireFox but not in IE...

    i made deep debugging and found that IE stuck at [Date.parse] inside convert() while firefox did the parse correctly.

    stack:
    convert();
    extractValues();
    extractData();
    readRecords();
    loadData();

    this should save you time in solving the issue.

    also these two stackoverflow links showing that IE fails to parse some formats:
    http://stackoverflow.com/questions/3...-parsing-error
    http://stackoverflow.com/questions/2...-a-date-object

    thanks
  4. #4
    Hi,

    You have to define date format 'recordField['dateFormat'] = 'Y-m-dTh:i:s';'
    <%@ Page Language="C#" %>
     
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
     
        <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js" type="text/javascript"></script>
     
        <script runat="server">
            [DirectMethod]
            public static DataTable GetScheduleInformation(long schNo)
            {
                DataTable table = new DataTable();
                table.Columns.Add("proposalDate", typeof(DateTime));
                table.Rows.Add(DateTime.Now);
                return table;
     
            }
             
        </script>
     
        <script type="text/javascript">
            createJsonStoreFromJsonResults = function(json) {
                /* prepare results for reader */
                var flds = [];
                $.each(json, function(n, v) {
                    var recordField = { 'name': n }
                    if (n != undefined && (n + "").toLowerCase().indexOf('date') > -1) {
                        recordField['type'] = 'date';
                        recordField['dateFormat'] = 'Y-m-dTh:i:s';
                    }
                    flds.push(recordField);
                });
                /* process results and convert them to bindable format */
                var store = new Ext.data.JsonStore({
                    idProperty: flds[0].name,
                    fields: flds
                });
                /* load json data into store */
                store.loadData(json, true);
                return store;
            }
     
            loadFormControls = function(sId) {
     
                Ext.net.DirectMethods.GetScheduleInformation(sId,
                 {
                     success: function(result) {
                         if (result[0].json == undefined) {
                             result[0] = createJsonStoreFromJsonResults(result[0]).getRange(0, 0)[0];
                         }
                         Ext.getCmp('fp1').getForm().loadRecord(result[0]);
                     },
                     failure: function(result) {
                         alert(result);
                     }
                 });
            }
        </script>
     
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:FormPanel runat="server" ID="fp1">
            <Items>
                <ext:Button runat="server" ID="btnLoad" Text="Bind">
                    <Listeners>
                        <Click Handler="loadFormControls(5);" />
                    </Listeners>
                </ext:Button>
                <ext:DateField runat="server" ID="dtProposalDate" FieldLabel="Proposal Date" DataIndex="proposalDate"
                    AnchorHorizontal="95%" Disabled="true" Format="dd/MM/yyyy" />
            </Items>
        </ext:FormPanel>
    </body>
    </html>
    Also, your sample can be simplified to the following one (please note that I set AltFormats for the date field)
    <%@ Page Language="C#" %>
     
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
     
        <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js" type="text/javascript"></script>
     
        <script runat="server">
            [DirectMethod]
            public static object GetScheduleInformation(long schNo)
            {
                return new { proposalDate = DateTime.Now };
            }
             
        </script>
     
        <script type="text/javascript">
            loadFormControls = function(sId) {
    
                Ext.net.DirectMethods.GetScheduleInformation(sId,
                 {
                     success: function(result) {
                         fp1.getForm().setValues(result);
                     },
                     failure: function(result) {
                         alert(result);
                     }
                 });
            }
        </script>
     
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:FormPanel runat="server" ID="fp1">
            <Items>
                <ext:Button runat="server" ID="btnLoad" Text="Bind">
                    <Listeners>
                        <Click Handler="loadFormControls(5);" />
                    </Listeners>
                </ext:Button>
                <ext:DateField runat="server" ID="dtProposalDate" FieldLabel="Proposal Date" DataIndex="proposalDate"
                    AnchorHorizontal="95%" Disabled="true" Format="dd/MM/yyyy" AltFormats="Y-m-dTh:i:s" />
            </Items>
        </ext:FormPanel>
    </body>
    </html>
  5. #5
    thank you very much...you the man!

    regarding the simplified code it's not gonna help me because this was only the test case but all DB objects returned as DataTables in my projects....anyway thanks for that!!

    please mark as solved!

Similar Threads

  1. [CLOSED] JSON object property: convert to Date value
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 14, 2012, 2:50 PM
  2. [CLOSED] Date is a string instead of Date object
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 01, 2012, 2:10 PM
  3. Replies: 0
    Last Post: Dec 02, 2011, 12:23 AM
  4. Replies: 1
    Last Post: Sep 13, 2011, 5:19 PM
  5. Replies: 4
    Last Post: Feb 01, 2011, 11:54 AM

Tags for this Thread

Posting Permissions