1. #1
    Sencha User env0ke's Avatar
    Join Date
    Apr 2011
    Posts
    57
    Vote Rating
    1
    Answers
    2
    env0ke is on a distinguished road

      0  

    Question Answered: Configure binding data

    Answered: Configure binding data


    Hi all,

    I try binding data from grid to simple panel. In grid i can use renderer:
    PHP Code:
    renderer Ext.util.Format.dateRenderer('d.m.Y'
    Template for panel:
    PHP Code:
    tplMarkup: [       
     
    '<table id="details">',      
      
    '<tr>',      
      
    '<th id="th">Insert date:</th>',       
      
    '<td id="td">{insert_date}</td>',       
      
    '</tr>'      
      '</table>' 

    And in {insert_date} i have Fri May 19 2011 00:00:00 GMT+0100 (CET), but i need 19.05.2011. What i can configure date? Sorry of my bad english .

  2. Here's one way:

    Code:
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: [
            'Date: {[Ext.util.Format.dateRenderer("d.m.Y")(values.insert_date)]}'
        ]
    });
    Here's another way:

    Code:
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: new Ext.XTemplate(
            'Date: {[this.formatDate(values.insert_date)]}',
            {
                formatDate: Ext.util.Format.dateRenderer('d.m.Y')
            }
        )
    });
    Here's a third alternative:

    Code:
    Ext.util.Format.myDateFormat = Ext.util.Format.dateRenderer("d.m.Y");
    
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: [
            'Date: {insert_date:myDateFormat}'
        ]
    });
    See the XTemplate docs for details of all of this.

  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


    Here's one way:

    Code:
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: [
            'Date: {[Ext.util.Format.dateRenderer("d.m.Y")(values.insert_date)]}'
        ]
    });
    Here's another way:

    Code:
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: new Ext.XTemplate(
            'Date: {[this.formatDate(values.insert_date)]}',
            {
                formatDate: Ext.util.Format.dateRenderer('d.m.Y')
            }
        )
    });
    Here's a third alternative:

    Code:
    Ext.util.Format.myDateFormat = Ext.util.Format.dateRenderer("d.m.Y");
    
    new Ext.panel.Panel({
        height: 300,
        renderTo: Ext.getBody(),
        title: 'Title',
        width: 300,
        data: {
            insert_date: new Date()
        },
        tpl: [
            'Date: {insert_date:myDateFormat}'
        ]
    });
    See the XTemplate docs for details of all of this.
    Last edited by skirtle; 12 Aug 2011 at 5:04 AM. Reason: Thought of other ways to do it.

  4. #3
    Sencha User env0ke's Avatar
    Join Date
    Apr 2011
    Posts
    57
    Vote Rating
    1
    Answers
    2
    env0ke is on a distinguished road

      0  

    Thumbs up


    Third alternative worked for me. Thank you!

Thread Participants: 1

Tags for this Thread