1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    224
    Vote Rating
    9
    Answers
    13
    dedoz will become famous soon enough

      0  

    Default Answered: Grid Field dateFormat in Tpl

    Answered: Grid Field dateFormat in Tpl


    Hi.
    Im trying to give a grid field with type = date a format (date format) when used in a tpl like the followin code
    Code:
     columns: [{
                header:'Example Column', 
                xtype:'datecolumn', 
                dataIndex:'epaFch', 
                format:'l j \\d\\e M Y',
                width: 250
            },
            {   header:'What i want column', 
                xtype:'templatecolumn', 
                tpl:'{epaFch}<br>{anotherDataIndex}', 
                width: 250
            }
    ]
    The first column shows the date with the format i want and its working fine. (included this column just as a example)

    The second column is using a template where i reference the date field epaFch, in this case shows the default date.toString() text.

    How can i t specify the format to use to render epaFch in that tpl ?
    is this posible ? if not whats the best aproach ?
    1) use a function in renderer : function() that returns the string i want ?
    2) define another column in my Model (calculated) with the string i want so i can reference it in the tpl
    3) In the server side generate another column like epaFchString that has what i want to show ?

    sorry for my english.

  2. Code:
    {
        header: 'What i want column',
        width: 250,
        xtype: 'templatecolumn',
        tpl: Ext.create('Ext.XTemplate', '{epaFch:this.myDateRenderer}<br>{anotherDataIndex}', {
            myDateRenderer: Ext.util.Format.dateRenderer('l j \\d\\e M Y')
        })
    }

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,625
    Vote Rating
    331
    Answers
    550
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Code:
    {
        header: 'What i want column',
        width: 250,
        xtype: 'templatecolumn',
        tpl: Ext.create('Ext.XTemplate', '{epaFch:this.myDateRenderer}<br>{anotherDataIndex}', {
            myDateRenderer: Ext.util.Format.dateRenderer('l j \\d\\e M Y')
        })
    }

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    224
    Vote Rating
    9
    Answers
    13
    dedoz will become famous soon enough

      0  

    Default


    thank you

Thread Participants: 1