Results 1 to 4 of 4

Thread: Ext.util.JSON.encodeDate question

  1. #1

    Default Ext.util.JSON.encodeDate question

    I have this at the top of my script to make my datetime output into MS JSON format at server POST:
    Code:
            Ext.util.JSON.encodeDate = function (d) {
                return "\"" + d.format('M$') + "\"";
            };
    It work so far with my grid, until after I added a formpanel for select the date, and copy to my grid. From the grid, ext stop output the MS JSON format when POST.

    But after that, if I re-select the data from the grid, that date output MS JSON format. Why? And how to fix this?


    this is my ext form:

    Code:
    var OrderForm = new Ext.form.FormPanel({
                id: 'OrderForm',
                layout: 'form',
                frame: true,
                renderTo: Ext.getBody(),
                width: 550,
                labelWidth: 110,
                autoHeight: true,
                record: null,
                items: [
                {
                    layout: "column",
                    items: [{
                        columnWidth: .5,
                        layout: "form",
                        items: [new Ext.form.DateField({
                            fieldLabel: 'Shipment Date',
                            name: 'ShipmentDate', width: 120, allowBlank: false
                        })]
                    }, {
                        columnWidth: .5,
                        layout: "form",
                        items: [new Ext.form.DateField({
                            fieldLabel: 'Request Date',
                            name: 'DateOfRequest', width: 120, allowBlank: false
                        })]
                    }]
                }
    
            ],
                buttons: [ {
                    text: 'Create',
                    handler: function (btn, ev) {
                        if (!OrderForm.getForm().isValid()) {
                        return false;
                    }
                    OrderForm.fireEvent('create', OrderForm, OrderForm.getForm().getValues());
                    OrderForm.getForm().reset();
                },
                    scope: this
                }],
                listeners: {
                   //copy to my grid
                    create: function (fpanel, data) {
                        var rec = new OrderGrid.store.recordType(data);
                        OrderGrid.store.insert(0, rec);
                    }
                }
            });
    my grid's column:
    Code:
     [
    ....
                    { header: 'Shipment Date', width: 100, sortable: true, editor: new Ext.form.DateField(),  dataIndex: 'ShipmentDate' },
                    { header: 'Request Date', width: 100, sortable: true, editor: new Ext.form.DateField(),  dataIndex: 'DateOfRequest' }....
                ];

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Did you actually look at the POSTed JSON to check that it is valid?

    What do you see when you do?

  3. #3

    Default

    Quote Originally Posted by Animal View Post
    Did you actually look at the POSTed JSON to check that it is valid?

    What do you see when you do?
    this is the Posted JSON:
    Code:
    {"CompanyId":178,"d":{"ShipmentDate":"07/14/2010","DateOfRequest":"07/15/2010"}}
    if I re-select the date from the grid:
    Code:
    {"CompanyId":178,"d":{"ShipmentDate":"\/Date(1280246400000)\/","DateOfRequest":"\/Date(1279123200000)\/"}}

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    BasicForm.getValues() will return the field values as Strings. You want BasicForm.getFieldValues() so you get Dates as values.

Similar Threads

  1. JSON-RPC and Ext.util.JSON.decode...???
    By madmike2k in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 12 Mar 2010, 11:21 AM
  2. Replies: 6
    Last Post: 17 Aug 2009, 12:49 PM
  3. Replies: 2
    Last Post: 13 Aug 2009, 8:49 AM
  4. Ext.util.JSON.decode(resp.responseText).x Syntax Question
    By StevenInc in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 25 Jul 2009, 2:32 PM
  5. Ext.util.JSON.decode(json) gives unterminated string literal
    By sapatel in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 Mar 2009, 7:20 AM

Posting Permissions

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