Results 1 to 9 of 9

Thread: Update datefield from a Grid

  1. #1
    Touch Premium Member msinn's Avatar
    Join Date
    Jul 2009
    Location
    in front of my pc
    Posts
    280

    Default Update datefield from a Grid

    Hello everybody,

    I've tried to find an answer to my problem, but unfortunately it wasn't the best day.

    My date in the GroupingStore, as the server sent it:

    Code:
    {
        name : 'startdate',
        type : 'date',
        dateFormat : 'd.m.Y'
    },
    My date in the EditorGridPanel:

    Code:
    {
         //xtype : 'datecolumn',
         header : 'Start',
         dataIndex : 'startdate',
         //format : 'd.m.Y',
         width : 80,
         sortable : true,
         renderer : Ext.util.Format.dateRenderer('d.m.Y'),
         editor : {
             xtype : 'datefield',
             format: 'd.m.Y',
             allowBlank : false,
             minValue : '01.01.2009',
             minText : 'Text',
             maxValue : (new Date()).format('d.m.Y'),
             maxText : 'Text'
          }
    },
    So I update the grid:

    Code:
    listeners : {
                afteredit : function(e) {
                    var conn = new Ext.data.Connection();
                    conn.request({
                                url : 'database/updateEmployee.php',
                                params : {
                                    hbe_id : e.record.data.hbe_id,
                                    field : e.field,
                                    value : e.value
                                },
                                success : function(resp, opt) {
                                    e.record.commit();
                                },
                                failure : function(resp, opt) {
                                    e.record.reject();
                                }
                            });
                }
            },
    The problem is that the changed date is sent in row format (please see the attachement), but the server waits on the same format as it sent it.

    Could you please show me were I do the mistake?

    Thanks a lot

    Marius
    Attached Images Attached Images
    First I would like to thank you for your time and knowledge

    Win 7 Ext JS 4.1.3 IE(6-9), FF17

  2. #2
    Touch Premium Member msinn's Avatar
    Join Date
    Jul 2009
    Location
    in front of my pc
    Posts
    280

    Default

    Nobody can answer hier such an easy question?
    How to convert de Date object into the string format d.m.Y with Ext JS before I sent it to the server? So difficult?

    Is this forum for beginners not allowed?

    Have a nice day
    First I would like to thank you for your time and knowledge

    Win 7 Ext JS 4.1.3 IE(6-9), FF17

  3. #3
    Sencha User
    Join Date
    Apr 2008
    Location
    Hong Kong
    Posts
    171

    Default

    use Ext.util.Format.date(e.value, 'Y-m-d')

  4. #4
    Touch Premium Member msinn's Avatar
    Join Date
    Jul 2009
    Location
    in front of my pc
    Posts
    280

    Default

    Thank you a lot jarlau!

    The problem is that I do not have just date fields, so first I must check if the event contains a date object.
    I've tried as bellow but I get an error in firebug:

    isDate(e)... is not defined

    I'm trying to learn Ext JS, so please, please, please tell me how to solve this problem.

    Code:
    listeners : {
                afteredit : function(e) {
                    var conn = new Ext.data.Connection();
                    conn.request({
                                url : 'database/updateEmployee.php',
                                params : {
                                    hbe_id : e.record.data.hbe_id,
                                    field : e.field,
                                    //value : e.value
                                    value : isDate(e) ? Ext.util.Format.date(e.value, 'd.m.Y') : e.value
                                },
                                success : function(resp, opt) {
                                    e.record.commit();
                                },
                                failure : function(resp, opt) {
                                    e.record.reject();
                                }
                            });
                }
            },
    Thank you again jarlau
    First I would like to thank you for your time and knowledge

    Win 7 Ext JS 4.1.3 IE(6-9), FF17

  5. #5
    Sencha User
    Join Date
    Apr 2008
    Location
    Hong Kong
    Posts
    171

    Default

    try Ext.isDate(Date.parseDate(e.value))

  6. #6

    Default

    is e.value represents startdate 's value ?
    I dont think so, you can try e.record.data.startdate

  7. #7
    Touch Premium Member msinn's Avatar
    Join Date
    Jul 2009
    Location
    in front of my pc
    Posts
    280

    Default

    @jarlau thank you for your help again
    I've tried so this time:

    Code:
    listeners : {
                afteredit : function(e) {
                    var conn = new Ext.data.Connection();
                    conn.request({
                                url : 'database/updateEmployee.php',
                                params : {
                                    hbe_id : e.record.data.hbe_id,
                                    field : e.field,
                                    //value : e.value
                                    value : Ext.isDate(Date.parseDate(e.value)) ? Ext.util.Format.date(e.value, 'd.m.Y') : e.value //row 274
                                },
                                success : function(resp, opt) {
                                    e.record.commit();
                                },
                                failure : function(resp, opt) {
                                    e.record.reject();
                                }
                            });
                }
            },
    but this error in firebug

    m is undefined
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() row-editor.js (Zeile 274)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-base.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous(Object field=Object initialConfig=Object events=Object, Tue Sep 08 2009 00:00:00 GMT+0200, Object type=date dateFormat=d.m.Y value=01.01.1940) ext-all.js (Zeile 11)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous([Object scope=Object options=Object 0=Object], function(), Object name=E) ext-base.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous(Object name=a) ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous([Object scope=Object options=Object 0=Object], function(), Object name=E) ext-base.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 11)
    anonymous() ext-all.js (Zeile 11)
    anonymous(Object browserEvent=Event mousedown button=0) ext-all.js (Zeile 11)
    y() ext-all.js (Zeile 7)
    anonymous() ext-all.js (Zeile 7)
    [Break on this error] Ext.DomHelper=function(){var s=null,j=/^...b.stopEvent();this.completeEdit()}}}});\n ext-all.js (Zeile 7)
    @Nagadev
    Thank you for your answer

    the e.value is for each field of the record. After editing a field the new value of the field is sent to the server. It works good, just when I edit data fields another date format is sent to the server as 'd.m.Y'.(see attachement above)

    Do you have any idea how to convert this date format with Ext JS before sending it to the server?

    Thank you all
    First I would like to thank you for your time and knowledge

    Win 7 Ext JS 4.1.3 IE(6-9), FF17

  8. #8
    Sencha User
    Join Date
    Apr 2008
    Location
    Hong Kong
    Posts
    171

    Default

    no need to use Date.parseDate(), just
    Code:
    value : Ext.isDate(e.value) ? Ext.util.Format.date(e.value, 'd.m.Y') : e.value
    should work.

  9. #9
    Touch Premium Member msinn's Avatar
    Join Date
    Jul 2009
    Location
    in front of my pc
    Posts
    280

    Default

    It works ,

    thank you jarlau, you are my first best helper.

    I whish you the best week

    Marius
    First I would like to thank you for your time and knowledge

    Win 7 Ext JS 4.1.3 IE(6-9), FF17

Posting Permissions

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