PDA

View Full Version : Toolbar settings in diferent files



alienwebz
8 Dec 2009, 8:33 PM
How can I create multiple items for a toolbar and keep the toolbar and items in a different file from where the toolbar is rendered?

ex.
file1.js

//all toolbar settings and itemsfile2.js

toolbar.render('toolbar');
//dynamically add/remove toolbar components that are in file1.js

CrazyEnigma
8 Dec 2009, 9:20 PM
Of course, I do it all the time, but can be problematic when managing at times, and it will break OO rules.

Here is an example.


var Today = new Date();


Then I can use Today in another javascript. So long as this is before when the reference is used. If the reference is within a function declaration, it will not be used until the function is invoked.

alienwebz
9 Dec 2009, 7:33 PM
ok but it will not display anything if i do it that way. Can someone give me an example using the toolbar component?

CrazyEnigma
10 Dec 2009, 7:24 AM
What exactly are you attempting? That's not what the title of your post says.

one.js


var toolbarCfg = ["Hello World",' ','->',{text:'My Button'}];


another.js


var panel = new Ext.Panel({
tbar: toolbarCfg,
html: 'Hello World!!!',
// More config
});


or

another_one.js


var panelCfg = {
html: 'Hello World',
// more config
};
Ext.apply(panelCfg, {tbar: toolbarCfg});
var panel = new Ext.Panel(panelCfg);


Replace with whatever toolbar you want.

alienwebz
10 Dec 2009, 5:15 PM
this what i am attempting:

one.js


var topbar = new Ext.Toolbar();two.js


function topbar_overload_adminlogin()
{
var topbar_adminlogin_items = ['->',{text:'Admin Login'}];

Ext.apply(topbar,{topbar_adminlogin_items});
}
three.js

topbar.render('ux-topbar');
topbar_overload_adminlogin()