[CLOSED] [1.0] Json Webservice DateTime Parsing Error

  1. #1

    [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    hi,

    I have MySql DB and the WebSerice Return Paging Object that being Transform to Json Object by the HttpProxy but the Json for DataTime look like this:

    "effectiveDate":"\/Date(1201809600000)\/"
    so the problem not with Json Reader yet its with Json Response, where ((System.DateTime)(row[column])).Date.ToString() have the format of "YYYY/MM/DD 12:00:00 am". but even i changed the mysql dataTime to .Net One "0/0/0000 12:00:00 am" and also returned the same thing...

    
    "effectiveDate":"\/Date(1201809600000)\/"
    please guide me to all resources that cover this parsing issue.?


  2. #2

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    I found a method to solve the webservice Json by converting DataTime object to string:

    ((System.DateTime)(row[column])).Date.ToString("s")
    but since its string the Json Reader need to now its "RecordFieldType.Date" otherwise it won't bind to my DateField Control...and I can't till the reader the recordType of my columns because at the time the reader created the dataTypes still not loaded from the webservice, so is there any way i can return in the webservice response DateTime object instead of string so that the reader will auto understand the correct recordType????
  3. #3

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    Hi,

    Please see DateFormat="M$" for the RecordField
  4. #4

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    well, that's might be provide solution but i want clarifications and other fixes:

    here how i'm using your snippet:

    foreach (var s in storeItems)
                {
                    reader.Fields.Add(s, RecordFieldType.Auto, "M$");
                }
    as i told before i have no access to the columnDataType so i added The dateFormat to All records in the Json Reader, I test it and the columns that have no date DataType was working fine so is that ok! or i might face a scenario where un Date Record parsed as Date???

    also in the Grid I use Renderer

    <ext:Column DataIndex="effectiveDate" Header="Effective Date">
                            <Renderer Format="Date" Fn="Ext.util.Format.dateRenderer('M d, Y')"  />
     </ext:Column>
    but it didn't work with "M$"!!!

    but if the reader record added like this:
    reader.Fields.Add(new RecordField(s,RecordFieldType.Date));
    then the above Renderer work fine!!

    Finally the DateField defined with format:
    <ext:DateField runat="server" ID="dtEffectiveDate" FieldLabel="Effective Date"
                    DataIndex="effectiveDate" Format="dd/MM/yyyy" />
    the control Binding after grid selection not working also in case of "M$"???

    Please help me figure out a solution for that!!

  5. #5

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    Hi,

    as
    i told before i have no access to the columnDataType so i added The
    dateFormat to All records in the Json Reader, I test it and the columns
    that have no date DataType was working fine so is that ok! or i might
    face a scenario where un Date Record parsed as Date???
    First, Store will not parse field as date if you don't set Type="Date" for the field (it will not be considered as date). So, first required condition: set Type="Date" for the RecordField which presents the date

    Second, You have to set correct DateFormat for the field. This format will be used during date parsing only (after receiving data from the server, before converting to the records). Therefore you have to set DateFormat="M$" to parse "\/Date(1201809600000)\/"

    also
    in the Grid I use Renderer
    <Renderer Format="Date" Fn="Ext.util.Format.dateRenderer('M d, Y')" />but
    it didn't work with "M$"!!!
    'dateRenderer' convert date (!!!not string) to the string representation therefore if store cannot parse date correctly then you will get empty value. Therefore as I mention you have to set Type="Date" for the field which represents a date (it is required, If you do not know field's type then the store can not know about it also because the string can contain anything)

    Finally
    the DateField defined with format: the
    control Binding after grid selection not working also in case of "M$"
    Once again, is it with field's Type="Date" or without?

    Please see the following sample in the SVN which correctly parse date from web service
    Ext.Net.Examples\Examples\GridPanel\Paging_and_Sor ting\JSON_WebService\Default.aspx

  6. #6

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    hi,

    sounds like I need to ask for new feature to be added in ext:column control.

    I already extended the control in my subclassed controls like this:

    public class mycolumn:Ext.Net.Column
    {
    private RecordFieldType jsonColumnType = RecordFieldType.Auto;
    
    public RecordFieldType JsonColumnType
      {
         get{ return jsonColumnType ;}
         set{jsonColumnType  = value;}
      }
    
    }
    so now when i iterate through grid columns to read the dataindex i read with it the JsonColumnType which is Auto by default, only if the column was of DataType System.DateTime the developer shall specify this in the column markup like

    JsonColumnType="Date"

    this feature required when some one doing big business application where the data loaded through json webservice in which the Store JsonReader created a way before the column datatype identified from the DAL.

    i hope that make sense...please give me feedback about it!

    thanks,
  7. #7

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    Hi,

    I am still not understand why is it required. Can you provide test sample how do you use it?
    You can use DateColumn if you need determine type by column
  8. #8

    RE: [CLOSED] [1.0] Json Webservice DateTime Parsing Error

    hi dude,

    i didn't know about the DateColumn. so the feature have no meaning...

    please ignore that and thanks,


Similar Threads

  1. Store Reader DateTime Parsing w/ milliseconds
    By Thinjon100 in forum 1.x Help
    Replies: 2
    Last Post: Nov 20, 2013, 10:03 AM
  2. [CLOSED] IE8: HTML Parsing Error
    By jsdeveloper in forum 1.x Legacy Premium Help
    Replies: 21
    Last Post: Feb 22, 2011, 1:36 PM
  3. [CLOSED] Help: Custom find recod with JSON webservice
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 28, 2010, 12:20 PM
  4. [1.0] - JSON Serialize DateTime Request
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 26, 2010, 1:56 PM
  5. Replies: 1
    Last Post: Jul 14, 2008, 7:07 PM

Posting Permissions