Results 1 to 3 of 3

Thread: WCF/Json Dates ..

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    146
    Answers
    9

    Default WCF/Json Dates ..

    I'm using a slight modification on Maicon Schelters OData proxy thats around here somewhere and I've managed to get some data out of my C# project and back into an Ext.js grid - I needed to add something like :

    ..
    { name:'StartDate', type:'date', dateFormat:'MS'},
    ..

    To get the dates to work..

    Then in my grid - I define the column :

    {
    dataIndex:'StartDate',
    header: 'Start Date',
    format:'Y-m-d H:i', editor: {xtype:'datefield',format:'Y-m-d H:i'},
    xtype:'datecolumn'
    } ,


    Now - when I edit any data (any data - even when I dont change data in this field) and try to sync it back - I get an extra \ on either side of my date..

    According to fiddler2 - when the date comes across from the server - its like this :

    "StartDate": "\/Date(695036587540)\/"

    When I send it back - its :

    "StartDate":"\\/Date(695036587540)\\/"

    Any ideas on whats adding it in - how I can remove it ?
    (it *seems* like it might be 'setOptions in ext-4.1.1/ext-all-debug.js - around line 37807)

    (the .net service is complaining "String was not recognized as a valid DateTime.")


    Any help would be much appreciated!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    I would use a real debugger like DevTools (Chrome) or FireBug and set a breakpoint and find out where this is happening. Perhaps proxy you mentioned? Do you want the Date() included?

    Scott.

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    146
    Answers
    9

    Default

    I think I've got fairly close now...


    I added a function :

    function fromMs(value) {
    return Ext.Date.parse(value,'MS');
    }


    and I call that :

    { name:'StartDate', type:'date',convert: fromMs},
    which *seems* to be working atm



    (I use this in a lot of places - so putting the conversion in a separate function makes sense for me...)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •