Aminesrine
Aminesrine

Reputation: 2140

Extjs4 Formatting date column in GridPanel

Normally it works like this:

{
   text:'title1',
   dataIndex: 'dataIndex1',
   renderer: Ext.util.Format.dateRenderer('d/m/Y')
},

But in the renderer I have a function. Like this:

{
                text:'title1',
                dataIndex: 'dataIndex1',
                renderer: function(value, p, r)
                {
                    my_store.clearFilter(true);
                    var index = my_store.findExact('cin',r.get('cin'));
                    var rec = my_store.getAt(index);
                    if(rec!=null)
                    {
                        return rec.get('dataIndex1')
                    }
                }
            }  

So how to add Ext.util.Format.dateRenderer('d/m/Y') to the function?

Upvotes: 0

Views: 4578

Answers (1)

dievardump
dievardump

Reputation: 2503

The value will be what renderer return.

So, if dataIndex1 is the value containing the date to Format, here is the function that should do it:

function(value, p, r) {
    var result = 0;
    my_store.clearFilter(true);
    var index = my_store.findExact('cin', r.get('cin'));
    var rec = my_store.getAt(index);
    if (rec != null) {
        result = rec.get('dataIndex1');
        return Ext.util.Format.date(result, 'm/d/Y');
    }
}

Upvotes: 3

Related Questions