[OPEN] [#224] Bug on serialization of DateFormat = "MS"

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#224] Bug on serialization of DateFormat = "MS"

    There is a bug in the Ext.Net.Utilities project that is preventing the correct serialization of DateTime columns on DataGrids:

    DateTime is serialized in MS format (/Date(xxxx)/) and there is a configuration to set this in Ext.Net in a ModelField (ModelField.DateFormat = "MS"), but, the DateTimeUtils, method ConvertNetToPHP, near line 216:

    case "M":
      final.Append("n");
    resulting in:

    {name:\"LastSeen\",type:\"date\",dateFormat:\"nS\"}],
    The correct behaviour would be serialize dateFormat: \"MS\" instead of \"nS\"

    BTW, why this Ext.Net.Utilities is not present in the premium source code access???
    Last edited by Daniil; May 01, 2013 at 6:46 AM. Reason: [OPEN] [#224]
  2. #2
    Hello!

    Welcome to our forum!

    Thank you for your report!

    Can you, please, provide sample to reproduce?
  3. #3
    Actually, we don't need a sample for this one. Vladimir and I are discussing.

    The defect will be fixed immediately.
    Geoffrey McGill
    Founder
  4. #4
    Ext.Net.Utilities is an open-source MIT licensed library with full source code available on GitHub, see

    https://github.com/extnet/Ext.NET.Utilities
    Geoffrey McGill
    Founder
  5. #5
    Please use M$ instead MS
    See
    https://examples2.ext.net/#/GridPane...ON_WebService/

    We will fix it soon (in 2.2.0 release)
  6. #6
    Fix has been committed to Ext.NET.Utilities project.

    We will be including this fix in the upcoming Ext.NET Pro 2.2.0 release.
    Geoffrey McGill
    Founder
  7. #7
    The M$ worked fine.

    Some suggestions:

    1) Create a overload with an Enum (DataFormat.Microsoft, DataFormat.ISO, etc.)

    2) When using MVC, obey the global Newtonsoft JSON configuration (usually we determine the type of Date serialization in the GlobalConfig on Global.asax, but Ext.JS don't apply those settings and always serializes date as MS format).

    3) Create some global Newtonsoft Configuration in Ext (just like MVC has)

    4) Enable M$ by default, because it is the default format for DateColumn

    Also, there is a side bug (I'm not sure if it is a bug):

    In my database, the dates are in UTC (GMT+0). When serialized, the date arrives in the client side with UTC value, but with my local timezone.

    Ex.: in the database, it is 16/04/2013 00:20 GMT+0
    In the client, it is 16/04/2013 00:20 GMT-3

    It should be GMT+0 or 16/04/2013 20:20 GMT-3

    But I'm guessing this is a serialization/DateTime issue, right?
  8. #8
    1) Create a overload with an Enum (DataFormat.Microsoft, DataFormat.ISO, etc.)
    Agreed. We can look into this. Will add as a feature request for now.

    2) When using MVC, obey the global Newtonsoft JSON configuration (usually we determine the type of Date serialization in the GlobalConfig on Global.asax, but Ext.JS don't apply those settings and always serializes date as MS format).

    3) Create some global Newtonsoft Configuration in Ext (just like MVC has)
    We need to do some work on enabling more settings for the Json Serialization/Deserialization. This is something I'm going to look into for the 2.3.0 release.

    4) Enable M$ by default, because it is the default format for DateColumn
    The DateColumn should be set with a DataTime object. The string is serialized into an ISO formatted string, such as "yyyy-MM-ddTHH:mm:ss". The "MS" format is not used by default.

    Also, there is a side bug (I'm not sure if it is a bug):

    In my database, the dates are in UTC (GMT+0). When serialized, the date arrives in the client side with UTC value, but with my local timezone.

    Ex.: in the database, it is 16/04/2013 00:20 GMT+0
    In the client, it is 16/04/2013 00:20 GMT-3

    It should be GMT+0 or 16/04/2013 20:20 GMT-3

    But I'm guessing this is a serialization/DateTime issue, right?
    I'm not sure how you're converting that client Date value into a string, but JavaScript Date objects are relative to the client machine.
    Geoffrey McGill
    Founder
  9. #9
    That's the point: I'm doing nothing out of the box =\ For some reason, the MS format is the default format (instead of ISO) and I have no control of serialization:

    My PetaPoco class:

    [Column] public DateTime? LastSeen { get; set; }
    My Ext model method:

    public static Ext.Net.ModelFieldCollection ExtModel = new Ext.Net.ModelFieldCollection
    		{
    			new Ext.Net.ModelField("ID", Ext.Net.ModelFieldType.Auto),
    			new Ext.Net.ModelField("Enabled", Ext.Net.ModelFieldType.Boolean),
    			new Ext.Net.ModelField("DisplayName", Ext.Net.ModelFieldType.String),
    			new Ext.Net.ModelField("Login", Ext.Net.ModelFieldType.String),
    			new Ext.Net.ModelField("PrimaryEMail", Ext.Net.ModelFieldType.String),
    			new Ext.Net.ModelField("Memo", Ext.Net.ModelFieldType.String),
    			new Ext.Net.ModelField("LastSeen", Ext.Net.ModelFieldType.Date, "M$"),
    		};
    My datagrid date column code:
    public static DateColumn.Builder DateTimeColumn(this HtmlHelper html, int flex, string caption, string dataFieldName, bool groupable = false)
    		{
    			return html.X().DateColumn()
    			           .Flex(flex)
    			           .Text(caption)
    			           .DataIndex(dataFieldName)
    					   .Format("c")
    					   .Renderer("var id=this.getId() + '-' + rowIndex + '-' + colIndex;setTimeout(function(){$('#' + id).easydate(window.easyDateOptions)},100);return value == null ? res('EasyDate_Never') : '<abbr id=\"' + id + '\">' + Ext.Date.subtract(value, Ext.Date.MINUTE, new Date().getTimezoneOffset()) + '</abbr>';")
    			           .Groupable(groupable);
    		}

    Generated javascript:
    columns:
    			{
    				items:
    				[
    				{xtype:"datecolumn",flex:2,dataIndex:"LastSeen",groupable:false,renderer:function(value,metadata,record,rowIndex,colIndex,store,view)
    						{
    							var id=this.getId() + '-' + rowIndex + '-' + colIndex;
    							
    							setTimeout(function(){$('#' + id).easydate(window.easyDateOptions)},100);
    							
    							return value == null ? res('EasyDate_Never') : '<abbr id="' + id + '">' + Ext.Date.subtract(value, Ext.Date.MINUTE, new Date().getTimezoneOffset()) + '</abbr>';
    						},
    						text:"Visto",
    						format:"c"
    					}
    Generated data serialization:
    {"data":[{"ID":"9ee5a2db-a5db-11e2-b2ac-f46d040a8d55","Enabled":true,"DisplayName":"Admin","Login":"admin","PrimaryEMail":"admin@admin.com","Memo":null,"LastSeen":"\/Date(1366137473250)\/"},{"ID
    Without the dataFormat = "M$" or "MS", the data serialization still uses Microsoft Format.

    It's all working, but, the defaults are not the expected ones, which will cause some troubles in MVC.

    As the timezone, the Date(1366137473250) represents Tue Apr 16 2013 15:37:53 GMT-0300 (E. South America Standard Time), but should be Tue Apr 16 2013 15:37:53 GMT+0000 (because here is 12:37 pm now, not 15:37 (3:37 pm))

    Nevertheless, with some fixed, all is working fine now... Thank you for the fast response. :)
  10. #10
    Can you demonstrate how you are binding the data to the Store. I'm assuming you are controlling the Serialization of the Data, which is using then using the default Microsoft DateTime serialization format.

    If the data is bound to the Store using Ext.NET, then the ISO format is used by default.
    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: May 22, 2012, 10:40 AM
  2. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  3. [CLOSED] DateField DateFormat "YYYY/MM/DD" SelectedValue
    By pattake in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 02, 2012, 1:19 AM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM

Tags for this Thread

Posting Permissions