1. #1
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    361
    Answers
    3
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default Answered: Basic object creation. How to customize a window?

    Answered: Basic object creation. How to customize a window?


    Starting point. This works. Guess I swiped it from an example.

    Code:
    winPlayer = Ext.create('widget.window', {
            title: 'Layout Window',
            closable: true,
            closeAction: 'hide',
            width: 600,
            minWidth: 350,
            height: 350,
            layout: 'fit',
            html: '<div id="flowplayer"></div>'
        })
    This plays a video in a floating window. Very nice.
    Now I want more of them. Time to make this into a component of my own.
    I understand in javascript I cannot have a "class definition".
    I'll get a kind of prototype object from Ext.define, and I'll be able to instantiate with Ext.create
    Ja?

    I move it into a file: app/window/Winplayer.js and the loader requires it. Good.

    How to instantiate an this object?
    I read the "new" keyword is only for simple javascript object.
    I read we want to stick with Ext.define and Ext.create

    But I see most components have "Instance Methods" like "new Ext.window.Window"
    This does not look like method signature at all? It's using the new keyword of the language?

    I've been trying all sorts of things. Currently my window looks like this:
    Code:
    Ext.define('v10.window.Winplayer', {
        extend: 'widget.window',
        alias:['widget.winplayer'],
        listeners: {
            show: this.onShow
        },
        initComponent: function() {
            console.log('initComponent winplayer');
            Ext.apply(this, {
                title: 'Play Me',
                closable: true,
                closeAction: 'hide',
                width: 640,
                height: 480,
                minHeight: 260,
                minWidth: 320,
                layout: 'fit',
                html: '<div id="winplayer"></div>',
            });
            this.callParent(arguments);
        },
        onShow: function(t,e) {
            console.log('on show')
        }
    },function(){
            console.log('winplayer created')
        }
    )
    In the app...
    var wp = Ext.create('widget.winplayer')

    throws no errors and allows me to set a title.

    But I can't call the show() method (it is not defined).
    I can see under Chrome that my instance isn't at all the same as the sample one.
    Truly missing all the goop that I expected to inherit from a window.

    Obviously I have misunderstood something. But what?
    Is window a peculiar object? Have I messed the widget alias thing?
    Which sample/example can I look at now...?

  2. you should extend the Ext class, not its widget name... so in your code use:

    Code:
     extend: 'Ext.window.Window'
    and you will be near...

  3. #2
    Sencha User
    Join Date
    May 2011
    Location
    Argentina
    Posts
    55
    Answers
    2
    Vote Rating
    2
    ferengidedalo is on a distinguished road

      0  

    Default


    you should extend the Ext class, not its widget name... so in your code use:

    Code:
     extend: 'Ext.window.Window'
    and you will be near...

  4. #3
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    361
    Answers
    3
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default


    Perfect thank you.

Thread Participants: 1