Header menu does not close in Chrome & is not destroyed

Hi,

I have a grid and a tree on my page. When a different node is activated in the tree, the grid will be thrown away and rebuilt with different data. In the grid the header menu is activated.

The problem is, that when the header menu is opened in Chrome and a different node is clicked in the tree, the old menu remains displayed while the grid is destructed and built new.

In dhtmlXGridObject.prototype.enableHeaderMenu you have those lines:

    dhtmlxEvent(document.body, "click", function () {
        b._hContext && b._showHContext(!1)
    });

But in Chorme this click handler is not executed when a tree node is clicked. Firefox does call it. I didn’t test any other browsers.

However, all browsers leave this._hContext behind when dhtmlXGridObject.destructor is called. This is a memory leak.

I circumvented this problem now with these lines:

	grid.destructor_ori = this.grid.destructor;
	grid.destructor = function () {
		if (this._hContext) {
			this._hContext.parentNode.removeChild(this._hContext);
			this._hContext = null;
		}
		this.destructor_ori();
	};

Cheers,
Michael

I have a problem that using dhtmlxgrid enableHeaderMenu().
If I did click blank area in a grid, header menu is not disappear.

So, I have tried to fix it.
I have added the code below.

dhtmlXGridObject.prototype.enableHeaderMenu = function (a) {
typeof a == “string” && (a = a.split(“,”));
this._hm_config = a;
var b = this;
this.attachEvent(“onInit”, function () {
this.hdr.oncontextmenu = function (a) {
return b._doHContClick(a || window.event)
};
this.startColResizeA = this.startColResize;
this.startColResize = function (a) {
return a.button == 2 || _isMacOS && a.ctrlKey ? this._doHContClick(a) : this.startColResizeA(a)
};
this._chm_ooc = this.obj.onclick;
this._chm_hoc = this.hdr.onclick;
this.hdr.onclick = function (a) {
if (a && (a.button ==
2 || _isMacOS && a.ctrlKey)) return !1;
b._showHContext(!1);
return b._chm_hoc.apply(this, arguments)
};

	this.objBox.onclick = function() {
        b._showHContext(!1);
        return b._chm_ooc.apply(this, arguments)
	}
	
    this.obj.onclick = function () {
        b._showHContext(!1);
        return b._chm_ooc.apply(this, arguments)
    }
});
dhtmlxEvent(document.body, "click", function () {
    b._hContext && b._showHContext(!1)
});
this.hdr.rows.length && this.callEvent("onInit", []);
this.enableHeaderMenu = function () {}

};

But it does not run on the left side of Frozen Mode(split mode).
Please check.

I tried a little bit more to solve this problem.
In Chrome browser, the problem was resolved.
Green is the newly added code.

dhtmlXGridObject.prototype.enableHeaderMenu = function (a) {
typeof a == “string” && (a = a.split(","));
this._hm_config = a;
var b = this;

this.attachEvent("onInit", function () {
    this.hdr.oncontextmenu = function (a) {
        return b._doHContClick(a || window.event)
    };
    this.startColResizeA = this.startColResize;
    this.startColResize = function (a) {
        return a.button == 2 || _isMacOS && a.ctrlKey ? this._doHContClick(a) : this.startColResizeA(a)
    };
    this._chm_ooc = this.obj.onclick;
    this._chm_hoc = this.hdr.onclick;
    this.hdr.onclick = function (a) {
        if (a && (a.button ==
            2 || _isMacOS && a.ctrlKey)) return !1;
        b._showHContext(!1);
        return b._chm_hoc.apply(this, arguments)
    };
	
	var fake = this._fake || null;
	if(fake) {
		this._chm_fooc = fake.objBox.onclick;
		fake.objBox.onclick = function(a) {
			b._showHContext(!1);
			return b._chm_fooc.apply(this, arguments)				
		}
		
		this._chm_foc = fake.obj.onclick;
		fake.obj.onclick = function(a) {
			b._showHContext(!1);
			return b._chm_foc.apply(this, arguments)				
		}
	}
	
	this._chm_oboc = this.objBox.onclick;
	this.objBox.onclick = function() {
        b._showHContext(!1);
        return b._chm_oboc.apply(this, arguments)
	}
	
    this.obj.onclick = function () {
        b._showHContext(!1);
        return b._chm_ooc.apply(this, arguments)
    }
});
dhtmlxEvent(document.body, "click", function () {
    b._hContext && b._showHContext(!1)
});
this.hdr.rows.length && this.callEvent("onInit", []);
this.enableHeaderMenu = function () {}

};

As a result, when you click the left side’s blank area in the frozen mode grid, it will be works well.
And if you press the left side’s rows in frozen mode grid, it will be perfectly running.

I wonder whether or not it happened already solved. :smiley: