Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Arun on Aug 20, 2009 07:01
open dhtmlx forum
dhtmlxmenu v 1.0 - contextmenu error - this.parentItem is null or not an object

Occasionally I get an error when I load a grid with a context menu. This happens usually the first time the page is loaded and every time after that I refresh the page, this error does not appear. Refresh of the page, will mostly load the page properly without any error, but I do get the same error once every few refresh attempts.

I am using dhtmlxmenu version 1 (and IE-8). The error seems to appear at the time of initialization of the menuobject:

The grid has a context menu.

Message: 'this.parentItem' is null or not an object
Line: 18
Char: 2
Code: 0
URI: .../scripts/dhtmlx/dhtmlxMenu/codebase/dhtmlxmenubar.js

Code:

<script src="<%=appName%>/scripts/dhtmlx/dhtmlxMenu/codebase/dhtmlxcommon.js"></script>
<script src="<%=appName%>/scripts/dhtmlx/dhtmlxMenu/codebase/dhtmlxprotobar.js"></script>    
<script src="<%=appName%>/scripts/dhtmlx/dhtmlxMenu/codebase/dhtmlxmenubar.js"></script>     
<script src="<%=appName%>/scripts/dhtmlx/dhtmlxMenu/codebase/dhtmlxmenubar_cp.js"></script>

// -- Define Context Menu
var shMenu;
shMenu=new dhtmlXContextMenuObject('120',0,'../imgs');
shMenu.menu.setGfxPath("../../scripts/dhtmlx/dhtmlxMenu/codebase/imgs/");
shMenu.setContextMenuHandler(selectShiftMenuOption);
shMenu.setContextZone('sp_shiftGrid',2);
shMenu.menu.loadXML("dhtmlxmenu_dls1.xml");
                                 
shiftGrid = new dhtmlXGridObject('sp_shiftGrid');
shiftGrid.setHeader("Start, Activity,");
shiftGrid.setNoHeader(true);
shiftGrid.setInitWidths("80,*,5,5");
shiftGrid.setColAlign("left,left,left,left");
shiftGrid.setColTypes("coro,coro,ro,ro");             
shiftGrid.setColSorting("str,str,str,ro");
shiftGrid.setSkin("xp");
shiftGrid.enableAutoHeight(true,"400");
shiftGrid.enableContextMenu(shMenu);
shiftGrid.enableLightMouseNavigation(true);        
shiftGrid.enableRowsHover(true,'lay_grid_hover');
shiftGrid.enableTooltips("false,false,false,false");
shiftGrid.init();

Menu XML:

<?xml version='1.0' ?>
<menu name="Shift Menu" absolutePosition="auto" mode="popup" maxItems="2" globalCss="contextMenu" globalSecondCss="contextMenu" globalTextCss="contextMenuItem">
    <MenuItem name="Insert task after" src="dls_insert.png" id="sh_insert"/>    
    <MenuItem name="Delete task" src="dash_delete.png" id="sh_delete"/>    
</menu>

Thanks
Answer posted by Alex (support) on Aug 20, 2009 07:31
The issue wasn't reproduced locally. Could you please send us the complete demo to re-create the issue (it can be sent to support@dhtmlx.com)