Results 1 to 5 of 5

Thread: Trouble writing extensions

  1. #1

    Default Trouble writing extensions

    I'm trying to write a very simple extension of Ext.tree.TreeNode, but I'm having some issues configuring instances of my extension. I can apply a config property in the extension code before calling initComponent(), but nothing I do in initComponent() changes any properties, even if I use Ext.apply:

    extensionObject = Ext.extend(Ext.tree.TreeNode, {
      someProp: someValue, // This does set someProp
      initComponent: function() {
        Ext.apply(this, {
          someProp: someOtherValue // This does not set someProp
        this.someProp = someNewValue; // This does not set someProp either
        myExtension.superclass.initComponent.apply(this, arguments);
    When I create a new instance of my extension, I cannot set any properties by passing a config object to the constructor, e.g.

    var extensionObject = new myExtension({someProp: someValue});
    does not set someProp. The only way I can set properties is after creation:

    var extensionObject = new myExtension();
    extensionObject.someProp = someValue;
    I don't know why none of these methods work because as far as I can tell they should all work equally well. Any ideas?

  2. #2


    Anybody? Seems like this should be fairly simple...all of the tuts use these methods for setting properties of extensions, don't know why they aren't working for me.

  3. #3


    Update: It seems like the initComponent() function of my extension never gets called. So the default values (before initComponent) set the properties, and never get overwritten from inside the extension. However, I still don't understand why passing a config object to a new extension instance wouldn't work.

  4. #4


    Found the problem: I was trying to extend Ext.tree.TreeNode. Because TreeNode is not a widget, it does not have an initComponent() method that it calls when it is created. So my initComponent() method was never called when I created a new instance of my extension.

    Does anybody know how I can extend a TreeNode in a similar manner?

  5. #5
    Ext User
    Join Date
    Jul 2007


    From the API DOCs
    TreeNode extends Node which extends Observable. initComponent is a template method for the Component Class so as you discovered initComponent isn't automatically called.

    Search for other extensions that extend Observable perhaps? Check

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts