admin管理员组文章数量:1394228
Is it possible to set a Ext JS ponent property (visibility, value, ...) to a specific value, smilar to jQuerys [.attr(attributeName, value)][1]
?
I'm getting the ponent name, the property/attribute name and the value and have to update the UI. My first solution works with a 'dictionary' (yes, i'm a c# developer) which calls the right method for the given attribute and supports visibility, value, enabled.
var methodMapper = {
"visibility" : function(p, value) {
if(value == "true" || value == "on" || value == "1" || value == "visible")
p.show();
else
p.hide();
},
"value" : function(p, value) {
p.setValue(value);
},
"enable" : function(p, value) {
if(value == "true" || value == "on" || value == "1" || value == "visible")
p.enable();
else
p.disable();
}
};
function receiveMessage(element, property, value) {
var func = methodMapper[property];
if(!func) return;
var p = Ext.getCmp(element); // retrieve ponent
func(p, value); // set property to value
}
Is there any better solution for setting the property in a ponent? I want to extend the supported properties to width, height, draggable, ... .
Is it possible to set a Ext JS ponent property (visibility, value, ...) to a specific value, smilar to jQuerys [.attr(attributeName, value)][1]
?
I'm getting the ponent name, the property/attribute name and the value and have to update the UI. My first solution works with a 'dictionary' (yes, i'm a c# developer) which calls the right method for the given attribute and supports visibility, value, enabled.
var methodMapper = {
"visibility" : function(p, value) {
if(value == "true" || value == "on" || value == "1" || value == "visible")
p.show();
else
p.hide();
},
"value" : function(p, value) {
p.setValue(value);
},
"enable" : function(p, value) {
if(value == "true" || value == "on" || value == "1" || value == "visible")
p.enable();
else
p.disable();
}
};
function receiveMessage(element, property, value) {
var func = methodMapper[property];
if(!func) return;
var p = Ext.getCmp(element); // retrieve ponent
func(p, value); // set property to value
}
Is there any better solution for setting the property in a ponent? I want to extend the supported properties to width, height, draggable, ... .
Share Improve this question edited Jan 16, 2012 at 11:40 Dr. Rajesh Rolen 14.3k42 gold badges110 silver badges180 bronze badges asked Jan 16, 2012 at 11:33 RobarRobar 1,9712 gold badges31 silver badges61 bronze badges1 Answer
Reset to default 4@Robar
If you want to work at the attributes of an HTML element, its better that you call getEl()
method on your ExtJS ponent (say panel) to get the element associated with the ponent and then you can get/set the attributes like how you do it in jQuery because in some cases you may not be able to map the attribute to a ponent property or method.
本文标签: javascriptSet propertyattribute in a ExtJS componentStack Overflow
版权声明:本文标题:javascript - Set propertyattribute in a ExtJS component - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744758251a2623593.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论