PDA

View Full Version : Wy does Renderer here not work?



martin911
27 Dec 2011, 10:05 PM
Hello,
I am using inside a Tab a Grid with three Colums see here:
var runwayTab = {
xtype: 'panel',
//height: 371,
title: 'RWY',
id: 'runwayTab',
items: [
{
xtype: 'gridpanel',
title: '',
store: 'AirportRunways',
columns: [
{
xtype: 'gridcolumn',
width: 50,
dataIndex: 'ident',
text: 'Ident'
},
{
xtype: 'numbercolumn',
width: 50,
dataIndex: 'bearing',
text: 'Bearing',
renderer: function(value){
if (value >= 0) {
return Ext.String.leftPad(value + '', 3, '0');
} else {
return '';
}

}
},
{
xtype: 'numbercolumn',
width: 50,
dataIndex: 'length',
format: '0',
text: 'Length'
}
]
}
]
};

The renderer for column two does not work. It show me:
30318
only the standard format 0.00 instead of 015 or 066.

Did I made something wrong??
Thank you for your help in advance!
rgds
martin

tvanzoelen
28 Dec 2011, 5:12 AM
If I see into the constructor of the NumberColumn, I think that your renderer is overwriten by the given format.



constructor: function(cfg) {
this.callParent(arguments);
this.renderer = Ext.util.Format.numberRenderer(this.format);
}


with callParent it wil set your rendererer and then it overwrties it with this.renderer = Ext.util.Format.numberRenderer(this.format);

Mayby it is best to extend the numbercolumn class and override this constructor with you own renderer.

jay@moduscreate.com
28 Dec 2011, 6:44 AM
Martin,

*please* post code in code tags.

I would say don't use a numbercolumn if you want a custom renderer.

martin911
28 Dec 2011, 2:51 PM
Hi Jay,
here the code in code tag.


var runwayTab = {
xtype: 'panel',
//height: 371,
title: 'RWY',
id: 'runwayTab',
items: [
{
xtype: 'gridpanel',
title: '',
store: 'AirportRunways',
columns: [
{
xtype: 'gridcolumn',
width: 50,
dataIndex: 'ident',
text: 'Ident'
},
{
xtype: 'numbercolumn',
width: 50,
dataIndex: 'bearing',
text: 'Bearing',
renderer: function(value){
if (value >= 0) {
return Ext.String.leftPad(value + '', 3, '0');
} else {
return '';
}

}
},
{
xtype: 'numbercolumn',
width: 50,
dataIndex: 'length',
format: '0',
text: 'Length'
}
]
}
]
};


Sorry for troubles. This was my first post ;)
rgds
martin