clearAll() not working for me

Hi.
I’m trying to load different context menus for different rows in grid.
When i understand right clearAll() should help unloading the previous menu and loading a new menu. For me clearAll() prevents the context menu from being rendered.

Here my code so far:

// Switch the contextual menu before rendering

[code]grid.onBeforeContextMenu = function(iD) {

    grid.clearAll(); // prevents contextual menu from rendering

if('register'===grid.getUserData(iD,"type")) 
	grid.context.loadXML("@home/context_register.xml");
else if('account'===grid.getUserData(iD,"type"))
	grid.context.loadXML("@home/context_account.xml");
return true;
};  grid.attachEvent("onBeforeContextMenu", grid.onBeforeContextMenu);[/code]

// Create the basic contextual menu

grid.context = new dhtmlXMenuObject(); grid.context.setIconsPath("../common/images/"); grid.context.renderAsContextMenu(); grid.enableContextMenu(context);

Hi

First of all it seems to me, that you wanted to cell here method clearAll for menu, not for grid.

But using clearAll in your case is now the right approach.
There is an online sample with dynamic contex menu:
dhtmlx.com/docs/products/dht … namic.html
Try to use something like this.