Results 1 to 9 of 9

Thread: Format Dates in a Editor Grid

  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default Format Dates in a Editor Grid

    Hi,

    I have an Editor Gird,


    I have formatted this so it passes the fields as dd/mm/yyyy to populate the grid, which works fine but when the data back for an update this is converted, which fails in the DB update, how can I force the information being sent to dd/mm/yyyy?

    PHP Code:
    field    dateofpurchase
    ID    16
    task    update
    value    Mon Nov 26 2007 00
    :00:00 GMT+0000 (GMT Standard Time

    PHP Code:
            header'Purchase Date',
            
    dataIndex'purchaseddate',
            
    width80,
            
    sortabletrue,
        
    format'm/d/Y',
            
    editor: new Ext.form.DateField({
                            
    allowBlankfalse
                              
    })
            },{ 
    Thanks,

    Sanj

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    the data field needs to be setup as 'type : 'date''

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default

    Thanks for your reply,

    I have added the tye as you requested:

    PHP Code:
    header'Purchase Date',
    dataIndex'dateofpurchase',
    width80,
    type'date',
    sortabletrue,
    format'd/m/Y',
    editor: new Ext.form.DateField({
            
    allowBlankfalse
                      
    })
            },{ 
    The dates seems OK after selecting but changes when I click the Save/Update button of the editor bar - I cannot see any other references to the date except the above line the 'roweditor.js file doesn't contain anything specific its just the generic file.

    Any ideas?

    Thanks,

    Sanjay

  4. #4
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Quote Originally Posted by [email protected] View Post
    the data field needs to be setup as 'type : 'date''
    <--------- data field is the "mapping" setup in the store!

  5. #5
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default

    Thanks,

    I think I am understanding, I have this as the store, so I need to add some format to the 'dateofpurchase', is this correct (format: 'dd/mm/yy')?

    PHP Code:
        var myRecordObj Ext.data.Record.create([
        {
    name'allocationname'mapping'allocationname'sortDir'ASC'sortType'asUCString'},
    {
    name'dateofpurchase'mapping'dop'},
    {
    name'invoicenumber'mapping'invoicenumber'},
    {
    name'purchasedfrom'mapping'purchasedfrom'},
    {
    name'itemcost'mapping'itemcost'}
             ]); 
    Quote Originally Posted by [email protected] View Post
    <--------- data field is the "mapping" setup in the store!

  6. #6
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    *sigh*~~~~~~


    add : type: 'date' to the FIELD mapping for the DATE FIELD!

  7. #7
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default

    Aplogies Garcia,

    This is driving me nuts (I'm usually able to sort these things out but am having a severe mental block!)

    I have added the type as requested:

    PHP Code:
      
        
    var myRecordObj Ext.data.Record.create([
    {
    name'allocationname'mapping'allocationname'sortDir'ASC'sortType'asUCString'},
    {
    name'dateofpurchase'mapping'dop'type:'date'},
    {
    name'invoicenumber'mapping'invoicenumber'},
    {
    name'purchasedfrom'mapping'purchasedfrom'},
    {
    name'itemcost'mapping'itemcost'}
            ]);


    .....
    header'Purchase Date',
    dataIndex'dateofpurchase',
    width100,
    type'date',
    sortabletrue,
    format'd/m/Y',
    editor: new Ext.form.DateField({
            
    format'd/m/Y',
            
    allowBlankfalse
                
    })
            },{ 
    The response for the store is correct:
    PHP Code:
    ({"total":"44","results":[{"assetID"14,"dop""30/08/2007" ,"invoicenumber""aaaaaaaaaa","purchasedfrom":... 

    But now the grid displays the dates as 'Wed Mar 07 2007 00:00:00 GMT+0000 (GMT Standard Time)'

    What am I missing?

  8. #8

  9. #9
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,232

    Default

    i've actually answered this a few times before.

    check out the following threads in the 2.x/3.x Help forums:
    http://www.extjs.com/forum/showthread.php?t=80374
    http://www.extjs.com/forum/showthread.php?t=70327

Posting Permissions

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