3.2.0

Code Contribution: Disabling a grid

Here is how I'm disabling/enabling a grid...

obj.disable = function() {
this.setStyle("filter", "alpha(opacity=25)");
this.setStyle("opacity", ".25");
this.setStyle("-moz-opacity", ".25");

function _disable(oObject, sEventName) {
oObject["_" + sEventName] = oObject.getEvent(sEventName);
oObject.setEvent(sEventName, "");
}

_disable(this, "onkeydown" );
_disable(this, "onmousewheel");
_disable(this.getTemplate("row"), "onclick" );

var oTmp = this.getTemplate("top/item");
_disable(oTmp, "onmousedown" );
_disable(oTmp, "onmouseenter");
_disable(oTmp, "onmouseleave");
_disable(oTmp.getContent("div"), "onmousedown" );
_disable(this.getTemplate("layout").getContent("scrollbars"), "onscroll");
};

// ------------------------------------------------------------

obj.enable = function() {
this.setStyle("filter", "alpha(opacity=100)");
this.setStyle("opacity", "1");
this.setStyle("-moz-opacity", "1");

function _enable(oObject, sEventName) {
oObject.setEvent(sEventName, oObject["_" + sEventName]);
}

_enable(this, "onkeydown" );
_enable(this, "onmousewheel");
_enable(this.getTemplate("row"), "onclick" );

var oTmp = this.getTemplate("top/item");
_enable(oTmp, "onmousedown" );
_enable(oTmp, "onmouseenter");
_enable(oTmp, "onmouseleave");
_enable(oTmp.getContent("div"), "onmousedown" );
_enable(this.getTemplate("layout").getContent("scrollbars"), "onscroll");
};

Any improvements/suggestions welcome.
Steve N
June 7,
When you disable the grid using given code, it works. But if you click on the disabled grid it creates an error. So you need to try, catch that error.
Error comes from followin function of grid.js

var dispatch=function(event,element){
var parts=element.id.split("/");
var tag=parts[0].split(".");
var obj=Active.System.all[tag[0]];
var type="_on"+event.type+"Event";
var i;
for(i=1;i<tag.length;i++){
var params=tag.split(":");
obj=obj.getTemplate.apply(obj,params)
}
var target=obj;
for(i=1;i<parts.length;i++){
target=target.getContent(parts[i])
}
if(window.HTMLElement){
window.event=event
}
/* ======= error ======== */
try{
[i]target[type].call(obj,event);

}
catch(error){}
/* ======= error ========= */
if(window.HTMLElement){
window.event=null;
}
return;
};
Chandika Gunawardhana
July 26,

This topic is archived.

See also:


Back to support forum