Nas
Nas

Reputation: 887

How to add multiple renderer in Ext JS Grid Columns

I have Ext JS Grid in which there is one numeric column on which I would like to add two type of renderer 1.colorRenderer: this renderer will decide whether to show numeric value in red or green based on value is less thn zero or greater thn zero 2. formatRenderer: this renderer is to format numeric value upto 2 decimal

adding something like in columns isn't working

renderer: colorRenderer, formatRenderer

one way i can write another ClubbedRenderer and inside that call both these renderer but that will make it cause unscalable solution and it need to get all permutation combination if new renderer comes

Upvotes: 0

Views: 2091

Answers (1)

Izhaki
Izhaki

Reputation: 23586

What's wrong with this:

renderer: function( aValue, aMeta, aRecord )
{
    aMeta.style = aValue >= 0 ? "color: #00FF00;" : "color: #FF0000;";
    return Ext.util.Format.number( aValue, '0.00' );
}

See a working JsFiddle.

Upvotes: 1

Related Questions