PDA

View Full Version : [CLOSED] new Ext.Toolbar.MenuButton Deprecated?



dap-perry
11 Jun 2009, 7:21 AM
Hi,

I have exsting code that dynamically creates a menu based on reading xml. Part of my routine creates new menu buttons using

var tbb = new Ext.Toolbar.MenuButton...

This works fine in ext 2.2.1, but doesnt work at all in v. 3. I really want to upgrade my extjs version to take care of the formatting issues with my menus in IE 8, but I don't want to have to re-write all my code. Usually new versions of libraries have backward compatibility, so I don't understand why version 3 does not.

Can someone give me a patch or something?

:) David

evant
11 Jun 2009, 7:24 AM
MenuButton = SplitButton in the new build.

dap-perry
11 Jun 2009, 7:35 AM
Hi Evan

While changing Ext.Toolbar.MenuItem to Ext.Toolbar.SplitButton causes the javascript not to error, it doesnt produce a menu either. Heres my routine (Sorry for formatting):

Ext.onReady(function(){
Ext.QuickTips.init();

//Read in XML Doc
var xmlString = document.getElementById("taXMLHolder").value;
var xmlMenuDoc = loadXMLString(xmlString);
//Create toolbar
var tb = new Ext.Toolbar();
tb.render('toolbarMenu');
//Create toolbar buttons
var xmlNodes = xmlMenuDoc.documentElement.selectNodes("./siteMapNode");
var intMenuID = 0;
for (var i=0;i < xmlNodes.length;i++)
{
xmlNode = xmlNodes[i];
xmlPageNodes = xmlNode.selectNodes("siteMapNode");
var title = xmlNode.getAttribute("title");
title = title.replace("~AMP~","&");
if (xmlPageNodes.length == 0) {
title = "&nbsp;&nbsp;" + title + "&nbsp;&nbsp;";
}
var tooltip = xmlNode.getAttribute("description");
tooltip = tooltip.replace("~AMP~","&");
var the_url = xmlNode.getAttribute("url");
the_url = the_url.replace("~AMP~","&");
var the_function = new Function("document.getElementById('ifrContent').src = '" + the_url + "';");
if (xmlPageNodes.length > 0) {
var tbb = new Ext.Toolbar.SplitButton(
{
id: 'tbb' + i,
text: title,
tooltip: tooltip,
handler: the_function
});
}
else {
var tbb = new Ext.Toolbar.Button(
{
id: 'tbb' + i,
text: title,
tooltip: tooltip,
handler: the_function
});
}
tb.add(tbb);

//Add any menus if applicable
if (xmlPageNodes.length > 0) {
var retObj = AddMenu(xmlNode,intMenuID);
tbb.menu = retObj.menu;
intMenuID = retObj.intMenuID;
}
}
window.ifrContent.onclick = function(e) { Ext.menu.MenuMgr.hideAll()};
});
function AddMenu(xmlObj,intMenuID) {
var menuid = 'menu'+intMenuID;
var menu = new Ext.menu.Menu(
{
id: menuid
});
intMenuID = intMenuID + 1;
var xmlNodes = xmlObj.selectNodes("siteMapNode");
for (var i=0;i < xmlNodes.length;i++) {
var xmlNode = xmlNodes[i];
var xmlSubNodes = xmlNode.selectNodes("siteMapNode");
var title = xmlNode.getAttribute("title");
title = title.replace("~AMP~","&");
var the_url = xmlNode.getAttribute("url");
the_url = the_url.replace("~AMP~","&");
the_url = String.fromCharCode(34) + the_url + String.fromCharCode(34);
var icon = xmlNode.getAttribute("icon");
icon = icon.replace("~AMP~","&");
var menuitem = new Ext.menu.Item(
{
text: title,
href: 'javascript:NavigateContent('+ the_url + ')',
icon: icon
});
menu.add(menuitem);
}
return {
menu: menu,
intMenuID: intMenuID
};
}
function loadXMLString(txt) {
try {
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(txt);
return(xmlDoc);
}
catch(e) {
try {
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");
return(xmlDoc);
}
catch(e) {
alert(e.message)
}
}
return(null);
}

dap-perry
11 Jun 2009, 1:45 PM
Don't worry about it. I found a way to insert a META tag and force IE 8 into compatibility mode. Until they come out with IE 9 and do away with compatibility mode I should be good.

Thanks,

:) David

mjlecomte
11 Jun 2009, 1:58 PM
Suggest you read these:

http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

http://extjs.com/learn/Ext_Forum_Help#Posting_a_working_showcase