zhegwood
30 Sep 2009, 1:58 PM
I know it can be done and I've done it before but I can't find an example of it anywhere...
Anyone have an example where a template has been applied to menu items?
Here's what I have that isn't working:
new Ext.menu.Menu({
floating:false,
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div>',
'<div style="float:left"><img src="{icon}" width="32" height="32" /></div>',
'<div style="float:left">',
'<div style="font-size:11px;font-weight:bold;">{text}</div>',
'<div style="">{subtext}</div>',
'</div>',
'</div>',
'<tpl for="children">',
'<div>',
'<div style="float:left"><img src="{icon}" width="16" height="16" /></div>',
'<div style="float:left">',
'<div style="font-size:11px;font-weight:bold;">{text}</div>',
'</div>',
'</div>',
'</tpl>',
'</tpl>'
),
items: this.getMenuItems()
});
getMenuItems: function() {
menuJson = [
{ icon:'images/icon.gif', text:'Heading Text', subtext:'subheading text', link:'http:www.extjs.com', children: [
{ icon:'images/subicon1.gif', text:'Sub 1', link:'' },
{ icon:'images/subicon2.gif', text:'Sub2', link:'' },
{ icon:'images/subicon3.gif', text:'Sub 3', link:'' },
{ icon:'images/subicon4.gif', text:'Sub4', link:'' },
]
}
return menuJson;
}
Anyone have an example where a template has been applied to menu items?
Here's what I have that isn't working:
new Ext.menu.Menu({
floating:false,
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div>',
'<div style="float:left"><img src="{icon}" width="32" height="32" /></div>',
'<div style="float:left">',
'<div style="font-size:11px;font-weight:bold;">{text}</div>',
'<div style="">{subtext}</div>',
'</div>',
'</div>',
'<tpl for="children">',
'<div>',
'<div style="float:left"><img src="{icon}" width="16" height="16" /></div>',
'<div style="float:left">',
'<div style="font-size:11px;font-weight:bold;">{text}</div>',
'</div>',
'</div>',
'</tpl>',
'</tpl>'
),
items: this.getMenuItems()
});
getMenuItems: function() {
menuJson = [
{ icon:'images/icon.gif', text:'Heading Text', subtext:'subheading text', link:'http:www.extjs.com', children: [
{ icon:'images/subicon1.gif', text:'Sub 1', link:'' },
{ icon:'images/subicon2.gif', text:'Sub2', link:'' },
{ icon:'images/subicon3.gif', text:'Sub 3', link:'' },
{ icon:'images/subicon4.gif', text:'Sub4', link:'' },
]
}
return menuJson;
}