javascript - Set propertyattribute in a ExtJS component - Stack Overflow

Is it possible to set a Ext JS ponent property (visibility, value, ...) to a specific value, smilar to

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 badges
Add a ment  | 

1 Answer 1

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744758251a4592012.html

相关推荐

  • javascript - Set propertyattribute in a ExtJS component - Stack Overflow

    Is it possible to set a Ext JS ponent property (visibility, value, ...) to a specific value, smilar to

    4小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信