about extend

  • I want to create myGridPanel extend Ext.grid.GridPanel.
    myGridPanel is more than Ext.grid.GridPanel that some attributes or methods.

    Ext.namespace('myGridPanel');
    myGridPanel = function() {
    myGridPanel.superclass.constructor.call(this);
    };
    Ext.extend(myGridPanel, Ext.grid.GridPanel, {
    myName : 'myName',
    setMyName : function(name) {
    this.myName = name;
    }
    })

    there is something wrong in my code. But i didn't know where is it.

    var grid = new myGridPanel( {
    store : store,
    cm : cm,
    viewConfig : {
    forceFit : true
    },
    plugins : expander,
    collapsible : true,
    animCollapse : false,
    title : 'here is the title',
    iconCls : 'icon-grid',
    renderTo : 'center-div'
    });

    like this , i use myGridPanel, the title didn't display. so i think there must be something wrong in my code about extend.


  • thank you , Condor!~

    but just have a little problem about this :
    MyGridPanel = function(config) {
    MyGridPanel.superclass.constructor.call(this, config);
    };
    what is the config's meaning?
    Ext.namespace('myns');
    myns.MyGridPanel = function(config) {...};//this config is what?


  • Oh, that is right!~

    Thank you again !~~I know it~!:)


  • The GridPanel constructor has a single parameter named config of type object (see API doc (http://extjs.com/deploy/dev/docs/?class=Ext.grid.GridPanel)).

    Didn't you notice you were already using it?

    var grid = new MyGridPanel({
    store : store,
    cm : cm,
    viewConfig : {
    forceFit : true
    },
    plugins : expander,
    collapsible : true,
    animCollapse : false,
    title : 'here is the title',
    iconCls : 'icon-grid',
    renderTo : 'center-div'
    });


  • You need to define the constructor WITH parameters, e.g.

    MyGridPanel = function(config) {
    MyGridPanel.superclass.constructor.call(this, config);
    };

    ps.
    1. Classes are commonly written in uppercase while instances are written in lowercase, e.g.
    var myGridPanel = new MyGridPanel({...});
    2. Namespaces are containers for classes ('packages'), not the class itself, e.g.
    Ext.namespace('myns');
    myns.MyGridPanel = function(config) {...};







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about about extend , Please add it free.