Categories | Question details Back To List | ||||||||||||||||||||||||||
DHTMLXMenu Reload hi Team, I have a Layout and I have attached a Menu with Layout using a XMl string return by a Web service, but on click on one menu Item I need to Load the menu again as My XML string is rolesbased and on click on menuy Item Role is gettig changed and webservice is returing diffrent XMLstring, but I am not able to attach this string. When I am truing to do so either Original keeps there or Menu disappers... Please help me in resolving the same: Small chunk of my code here: var COPMenu = window.COPMenu || {}; COPMenu = function() { function onClick(id, zoneId, casState) { if ((id == "m10-1") || (id.indexOf("md1-")!=-1)) { MainMenu = null COPMenu.initMainMenu(); COPMenu.hideMenuItems(); } } /** @private */ function success(result) { MainMenu.loadXMLString(result); COPMenu.hideMenuItems(); } /** @private */ function failure() { } // public methods /** @scope COPMenu */ return { /** Initialize the main (top) menu */ initMainMenu: function() { MainMenu = Layout1.attachMenu(); MainMenu.setImagePath(imgPathMenu); MainMenu.setIconsPath(imgMenuIconPath); COPMenu.getMainMenu(); MainMenu.attachEvent("onClick", onClick); GUITools.LogMessage('MainMenu Initialized', 1); }, /** * Gets the main menu data either from a static xml file or from the WCF service */ getMainMenu: function() { if (isStaticData) { MainMenu.loadXML(xmlLoanMainMenu,COPMenu.hideMenuItems); } else { var obj = new GUIServices.GUIService(); obj.GetMainMenu(success, failure); } }, /** * Function to hide menu items based on Dashboard / Loan Mode */ hideMenuItems : function(){ COPMenu.hide("m2"); COPMenu.hide("m3"); COPMenu.hide("m4"); COPMenu.hide("m5"); COPMenu.hide("m6"); COPMenu.hide("m10-2"); }, /** * Function to show menu items based on Dashboard / Loan Mode */ showMenuItems : function(){ COPMenu.show("m2"); COPMenu.show("m3"); COPMenu.show("m4"); COPMenu.show("m5"); COPMenu.show("m6"); }, /** Hides a main (top) menu Item * @param id ID of the Menu Item that is to be hidden */ hide: function(id) { MainMenu.hideItem(id); GUITools.LogMessage('MainMenu Item Hidden', 1); }, /** Shows a main (top) menu Item * @param id ID of the Menu Item that is to be shown */ show: function(id) { MainMenu.showItem(id); GUITools.LogMessage('MainMenu Item Shown', 1); }, /** Disables a main (top) menu Item * @param id ID of the Menu Item that is to be disabled */ disable: function(id) { MainMenu.setItemDisabled(id); GUITools.LogMessage('MainMenu Item Disabled', 1); }, /** Enables a main (top) menu Item * @param id ID of the Menu Item that is to be enabled */ enable: function(id) { MainMenu.setItemEnabled(id); GUITools.LogMessage('MainMenu Item Enabled', 1); } }; } (); Regards Shalini Answer posted by Alex (support) on Nov 23, 2009 03:14 Hello, you can try to use clearAll and loadXML (loadXML string) method to reload menu: http://dhtmlx.com/docs/products/dhtmlxMenu/samples/01_init/09_clearall.html Answer posted by Shalini on Nov 23, 2009 03:19 but we are using 2.1 and these options are not available here.. Answer posted by Alex (support) on Nov 23, 2009 07:01 clearAll method is the following: dhtmlXMenuObject.prototype.clearAll = function() { for (var a in this.itemPull) { this.removeItem(String(a).replace(this.idPrefix,"")); } } this._isInited = false; } Try to add it to the page with menu to use it. Answer posted by Shalini on Nov 24, 2009 03:55 Hi Alex, When I added this function(clearAll) in my DHTMLXMenu.js and called this function from:
/** @private */ MainMenu.loadXMLString(result); its giving me attached error: Please help me in resolving the same: Thanks Shalini
Attachments (1)
Answer posted by Alex (support) on Nov 24, 2009 05:52 Hello, the issue is confirmed. We have attached the sample that contains fixed dhtmlxmenu.js Attachments (1)
Answer posted by Shalini on Nov 24, 2009 21:35 Hi alex,
I replaced my DHTMLXMenu.js with new Js used in above sample, but its still giving me some error,Error is attached. Please Advise.. Regards Shalini Attachments (1)
Answer posted on Nov 24, 2009 21:50 hi alex, its working fine now, i forget to add clearall function on my page, but still I have an issue that its changing the Order of Menus and submenu, which were not loaded first time in the system and getting added in reload functionality are coming at the Last position in Menu... Please help.. Regards Shalini
Answer posted by Alex (support) on Nov 25, 2009 02:02 Hello, please provide the complete demo to recreate the issue (sample should be without server-side scripts) Answer posted on Nov 25, 2009 02:25 hi alex,
Please find the sample attached. I have removed <item id='new' text='New' img='new.gif'/> item from First XML and then added this in second XML at same loctioon but coming as last Submenu of File Menu. Regards Shalini
Attachments (1)
Answer posted by Alex (support) on Nov 25, 2009 07:39 The issue is confirmed. To fix it please add the highlighted line in the end of the clearAll method: dhtmlXMenuObject.prototype.clearAll = function() { Answer posted on Nov 25, 2009 21:09 Thanks Alex, its working fine now... Shalini |