DHTMLXContextMenu: 'this.setGfxPathA' is null or not an Obje

This error just won’t stop bothering me…



I guess it comes from somewhere here dhtmlxmenubar.js and very probably is something pretty silly but I just can’t put my finger on it…





function dhtmlXMenuBarObject(htmlObject,width,height,name,vMode,gfxPath,httpsdummy){

    if (typeof(htmlObject)!=“object”)

        this.parentObject=document.getElementById(htmlObject);

    else

        this.parentObject=htmlObject;

    

    if (!this.parentObject)

        this.parentObject=document.body;

    

    this.setGfxPathA=this.setGfxPath;

    

    this.setGfxPath=function(){

        this.setGfxPathA.apply(this,arguments);

        var self=this;        

        

        dhtmlXMenuItemObject.prototype.dummyImg=function(){

            return self.sysGfxPath+“blank.gif”}

    };





I use the following code in my script:



cMenu=new dhtmlXContextMenuObject(‘120’,0, “some folder”);









Thanks

In which order you are including js files on your page?
The correct one is
    dhtmlxcommon.js
    dhtmlxprotobar.js
    dhtmlxmenubar.js

if you are using different order of files ( protobar after menubar ) - the mentioned issue may arise.

I am using the context menu on the dhtmlxtree component meaning that I have all the following includes:

   
   
   
   
   
   
   


Btw, which one of the dhtmlxcommon should I use first? At first glance, I would say they should be the same and the order has no importance, but since they are different inside (some slight changes), I am not that sure about that…


I switched the order but still can’t execute this:

function getInitialTree(){        
            initDhtmlXContextMenu();    
            tree=new dhtmlXTreeObject(‘treeBox’,“100%”,“100%”,0);
            tree.enableContextMenu(cMenu);
             …
}

function initDhtmlXContextMenu() {
            cMenu=new dhtmlXContextMenuObject(‘120’,0);
            //create menu item
            var item = new dhtmlXMenuItemObject(“Refresh Tree”,“Tree”,“1”,"",“contextMenu”);
            cMenu.menu.addItem(cMenu.menu,item);   
}

It gives me an “Object doesn’t support this property or method” exception

Precision:

It complains about the tree.enableContextMenu() method because when commented everything runs just fine;

I switched the order but still can’t execute this:

function getInitialTree(){        
            initDhtmlXContextMenu();    
            tree=new dhtmlXTreeObject(‘treeBox’,“100%”,“100%”,0);
            tree.enableContextMenu(cMenu);
             …
}

function initDhtmlXContextMenu() {
            cMenu=new dhtmlXContextMenuObject(‘120’,0);
            //create menu item
            var item = new dhtmlXMenuItemObject(“Refresh Tree”,“Tree”,“1”,"",“contextMenu”);
            cMenu.menu.addItem(cMenu.menu,item);   
}

It gives me an “Object doesn’t support this property or method” exception

I am using the context menu on the dhtmlxtree component meaning that I have all the following includes:

   
   
   
   
   
   
   


Btw, which one of the dhtmlxcommon should I use first? At first glance, I would say they should be the same and the order has no importance, but since they are different inside (some slight changes), I am not that sure about that…


Well, I see… For some reason, the method enableContextMenu() wasn’t shipped with the dhtmlxtree.js library;
It’s probably a licence issue of some kind :slight_smile:

Nevertheless, having the source code in front of me, I managed to add a little method enableContextMenu() on my one which basically just assigns the new menu value to the one inside the tree; that way I manage to get my popup menu popping :slight_smile: The problem is that whenever I try to click on it or anywhere else for that matter, nothing happens and the same exception Object doesn’t support this property or method exception arises. What am I missing?

Here is the code:

function initDhtmlXContextMenu() {
            cMenu=new dhtmlXContextMenuObject(‘150’,0, “MyOhMy”);
            var item = new dhtmlXMenuItemObject(“TreeMenu”,“One”,“1”,"",“contextMenu”);
            cMenu.menu.addItem(cMenu.menu,item);
            cMenu.setContextMenuHandler(onMenuClick);
               
        }
       
        function onMenuClick(idNode,idZone){
            alert(“yeah”);
        }

I found the problem;

Here is the bug you, guys, are certainly very much aware of:

    //dhtmlXMenuBarObject.prototype.correctMenuPosition=dhtmlXContextMenuObject.prototype.correctMenuPosition;

This thing has got to be commented in the dhtmlxmenubar_cp.js file!!!

Geee man.


Thanks.

For some reason, the method enableContextMenu() wasn’t shipped with the dhtmlxtree.js library;
Yes, this functionality available only in pro version, but it doesn’t do any magic, it just use
    menu.setContextZone(…
against tree items, so it can be reflected with custom code.

>>This thing has got to be commented in the dhtmlxmenubar_cp.js file!!!
Actually if you have order of js includes as
    dhtmlxmenubar.js
    dhtmlxmenubar_cp.js

on moment of line executing the dhtmlXMenuBarObject and dhtmlXContextMenuObject.prototype.correctMenuPosition are both defined, so it must not cause any problem
( the online samples use the same version of code by the way )

We will double-check the code, but so far it seems correct ( in any case, commenting this line will not break any important functionality )