1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    5
    Vote Rating
    0
    ssenlighta is on a distinguished road

      0  

    Default Unanswered: Formatting and rendering multiple values into a row cell

    Unanswered: Formatting and rendering multiple values into a row cell


    Hi, everyone
    I am just a newbie in this framework;
    Have gotta problem displaying two date values (end_date and start_date; both are not formatted yet) in a one cell (simultaneously):
    1. Formatting two dates in a cell
    2. Displaying them in a cell
    Thank you in advance

  2. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    Keeping in mind that I have no idea about the format of your inbound date values:

    Add a renderer to the start_date column, as shown below.

    Code:
    columns: [{
      header: 'Date Range',  dataIndex: 'start_date', width: 180, renderer: 
        function(value, metaData, record, rowIndex, colIndex, store) {
           return Ext.Date.format(value, 'm/d/Y')
              + " - " + 
              Ext.Date.format(record.get('end_date'), 'm/d/Y);
        }
    }]
    This renderer assumes that your model declares both the start_date and end_date fields as type 'date' with a 'dateFormat' set appropriate to the format of the inbound date values. In the example below, the dates are in the ISO-8601 compatible format of 'yyyy-mm-dd hh:mmss':

    Code:
    Ext.define('SomeModel', {
      extend: 'Ext.data.Model',
      fields: [
        {name: 'start_date', type: 'date', dateFormat: 'c'},
        {name: 'end_date', type: 'date', dateFormat: 'c'}
      ]
    });
    Last edited by friend; 27 Dec 2012 at 1:54 PM. Reason: formatting

Thread Participants: 1