PDA

View Full Version : call function in view config



lenoil
29 Mar 2013, 6:48 AM
Hi,

I want to call function to construct my config but it doesn't work.
The function getBtnTBar is not knew ... I understand but how get around this problem ?

My code


Ext.define("PAP.view.Main", {
extend: 'Ext.Panel',
xtype: 'main',
id:'mainTabPanel',
requires: [ "PAP.ux.OpenLayersMap"],
config: {
layout: {
type: 'hbox'
},
items: [
{
xtype: 'toolbar',
docked: 'top',
layout: {
pack: 'center',
type: 'hbox'
},
items:this.getBtnTBar()
},
{
xtype: 'ports'

},
{
// Ext.ux.OpenLayersMap Component
flex : 1,
xtype: 'openlayersmap',
id: 'openlayersmap'
}
]
},
getBtnTBar : function()
{
var isSeeBtnLocalisation = PAP.config.Constants.btnLocalisation;
var btnTbar = [
{
xtype:'img',
src:PAP.config.Constants.logo.src,
height: PAP.config.Constants.logo.height,
width: PAP.config.Constants.logo.width
},
{
xtype:'spacer'
},
{
id:'btnSearch',
xtype : 'button',
iconCls: 'search',
iconMask:true
}
,
{
id:'btnZoomMinus',
xtype : 'button',
iconCls: 'minus',
iconMask:true
},
{
id:'btnZoomAdd',
xtype : 'button',
iconCls: 'add',
iconMask:true
}
];


var btnLocate = {
id:'btnLocate',
xtype : 'button',
iconCls: 'locate',
iconMask:true
};
if (isSeeBtnLocalisation) btnTbar.push(btnLocate);

var spacer = {
xtype:'spacer'
};
btnTbar.push(spacer);

return btnTbar;

}

});


What's the best road for developp this ?

Thanks

lenoil
29 Mar 2013, 8:35 AM
Is This solution is the best ?
Thanks for your mind


Ext.define("PAP.view.Main", {
extend: 'Ext.Panel',
xtype: 'main',
id:'mainTabPanel',
requires: [ "PAP.ux.OpenLayersMap"],
config: {
layout: {
type: 'hbox'
}
},
initialize : function()
{
this.callParent(arguments);
var tbarButtons = [
{
xtype:'img',
src:PAP.config.Constants.logo.src,
height: PAP.config.Constants.logo.height,
width: PAP.config.Constants.logo.width
},
{
xtype:'spacer'
},
{
id:'btnZoomExtent',
xtype : 'button',
iconCls: 'zoomextent',
iconMask:true
}
,
{
id:'btnSearch',
xtype : 'button',
iconCls: 'search',
iconMask:true
}
,
{
id:'btnZoomMinus',
xtype : 'button',
iconCls: 'minus',
iconMask:true
},
{
id:'btnZoomAdd',
xtype : 'button',
iconCls: 'add',
iconMask:true
}

];
if (PAP.config.Constants.btnLocalisation != null)
{
if (PAP.config.Constants.btnLocalisation == true)
{
tbarButtons.push({
id:'btnLocate',
xtype : 'button',
iconCls: 'locate',
iconMask:true
});

}
}
tbarButtons.push({
xtype:'spacer'
});

this.add(
[
{
xtype: 'toolbar',
docked: 'top',
layout: {
pack: 'center',
type: 'hbox'
},
items:tbarButtons

},
{
xtype: 'ports'

},
{
// Ext.ux.OpenLayersMap Component
flex : 1,
xtype: 'openlayersmap',
id: 'openlayersmap'
}
]
);
}

});