View difference between Paste ID: SGjeMAz3 and LDeHPAAT
SHOW: | | - or go back to the newest paste.
1
App.SuperPanel = Ext.extend(Ext.Panel, {
2
    // initComponent вызывается у всех компонентов, которые видны
3
    // если надо расширить какой-то store - юзай constructor вместо initComponent
4
    initComponent: function(){
5
        // applyIf применяет только если параметры не переданы
6
        Ext.applyIf(this, {
7
            title: 'defaultTitle',
8
            html: 'defaultHtml',
9
            buttons: [{
10
                text: 'defaultButton',
11
                handler: function(){
12
                    console.log('default handler');
13
                    console.log(this);
14
                    console.log(this.ownerCt);
15
                }
16
            }]
17
        });
18-
        // apply применяет полюбому
18+
        // apply применяет полюбому и перетирает то, что отдано при инициализации
19
        // apply лучше юзать ПОСЛЕ applyIf, чтоб он перетер все ненужное
20
        Ext.apply(this, {
21
            closable: true
22-
        // парентовый конструктор
22+
23
        // парентовый initComponent. опять же, если будешь экстендить какой-то store, то
24
        // надо будет вызывать {ObjectName}.superclass.constructor.call(this)
25
        App.SuperPanel.superclass.initComponent.call(this);
26
    }
27
});
28
29
// defaults
30
new App.SuperPanel({});
31
32
new App.SuperPanel({
33
    title: 'title changed'
34
});
35
36
new App.SuperPanel({
37
    html: 'html changed'
38
});
39
40
new App.SuperPanel({
41
    buttons: [{
42
        text: 'button changed'
43
    }]
44
});
45
46
new App.SuperPanel({
47
    title: 'everything changed, except closable',
48
    html:  'everything changed, except closable',
49
    closable: false,
50
    buttons: [{
51
        text:  'everything changed, except closable'
52
    }]
53
});