PDA

View Full Version : [FIXED-1118] CompositeField.setReadOnly(false) sets ReadOnly to true



grubincan
13 Jul 2010, 9:23 AM
Ext version tested:

Ext 3.2.1


Adapter used:

ext


css used:

only default ext-all.css


Browser versions tested against:

IE8
FF3
Safari 5


Operating System:

OSX
WinXP Pro


Description:

The setReadOnlyMethod(readOnly) of CompositeField attempts to set a default value for the parameter. The parameter is boolean, so it always sets it to true, even if you pass false.





From CompositeField.js

//override the behaviour to check sub items.
setReadOnly : function(readOnly) {
readOnly = readOnly || true;

if(this.rendered){
this.eachItem(function(item){
item.setReadOnly(readOnly);
});
}
this.readOnly = readOnly;
},

Jamie Avins
13 Jul 2010, 12:04 PM
[type]: fix
[module]: CompositeField
[id]: #1118
[desc]: Fixes #1118. Fix logic in the setReadOnly method to check for undefined specifically and force boolean on the passed value.

WixSL
13 Jul 2010, 4:21 PM
I think the same happens in one more place.
In Ext.layout.AccordionLayout.beforeExpand method:



beforeExpand : function(p, anim){
var ai = this.activeItem;
if(ai){
if(this.sequence){
delete this.activeItem;
if (!ai.collapsed){
ai.collapse({callback:function(){
// p.expand will be called with true if anim==false
p.expand(anim || true);
}, scope: this});
return false;
}
}else{
ai.collapse(this.animate);
}
}
this.setActive(p);
if(this.activeOnTop){
p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
}

this.layout();
}

Jamie Avins
13 Jul 2010, 4:50 PM
I think the same happens in one more place.
In Ext.layout.AccordionLayout.beforeExpand method:



beforeExpand : function(p, anim){
var ai = this.activeItem;
if(ai){
if(this.sequence){
delete this.activeItem;
if (!ai.collapsed){
ai.collapse({callback:function(){
// p.expand will be called with true if anim==false
p.expand(anim || true);
}, scope: this});
return false;
}
}else{
ai.collapse(this.animate);
}
}
this.setActive(p);
if(this.activeOnTop){
p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
}

this.layout();
}


No idea what you are referring to. You may want to open a new thread.

WixSL
13 Jul 2010, 6:31 PM
What i meant was that the line "p.expand(anim || true);" in the above code has the same problem that
the fixed code "readOnly = readOnly || true;" from the first post.

May be i'm wrong.