Abdul Rehman Yawar Khan
Abdul Rehman Yawar Khan

Reputation: 1087

Pass data between views in ExtJS

I am reading data from store and populating main girdView. When any of the row is clicked, a windows appear and I want to fill the fieldset in that window with the same record which is clicked. Can anyone tell me how to do it?

My popup window is like:

{
    extend: 'Ext.window.Window',

    height: 500,
    width: 1500,
    minWidth :1500,
    maxWidth :1500,
    layout: 'fit',
    controller: 'PopUpWindowController',

    initComponent: function () {

        var me = this;


        //console.log(me.myExtraParams);
        var Store = Ext.getStore('mainStore');

        Ext.applyIf(me, {
         /*   items: [{
                xtype: 'form',
                bodyPadding: 10,
                region: 'center'
            }]*/

        });    
        me.callParent(arguments);
    },      
        items: [
    {      
        xtype: 'panel',
        title : 'Projektierung',
        bodyStyle : 'padding:5px',
        width : 1880,
        autoHeight : true,
        items:
        [ 
            {
                xtype  : 'kopfdatenView', // Have to populate this view
            }
        ]
}]}

and in Main view I am calling it as:

{ region: 'center', xtype: 'gridpanel',

            listeners : {
                itemdblclick: function(dv, record, item, index, e) {

                    var extra = record.data;
                    win = Ext.create('App.view.PopUpWindow');

                    console.log(win.myExtraParams);

                    win.on('show', function(win) {

                     win.setTitle(record.get('ID'));
                    });

                    win.show();
                }
            },

             columns: [
                      ****
                    ],
            store: 'mainStore', 
            height: 100,
            width: 400,

        }

I want to populate fieldset in kopfdatenView. Kindly help

Upvotes: 1

Views: 2188

Answers (2)

xaume
xaume

Reputation: 134

You can do something like this:

 win = Ext.create('App.view.PopUpWindow', {
           params: record
       });

Then, in your PopUpWindowController you can retrieve 'params' in the render event (for example).

Upvotes: 2

3rgo
3rgo

Reputation: 3153

You directly pass your record to your window on creation :

win = Ext.create('App.view.PopUpWindow', {
    myRecord: record
});

And then inside the window's initComponent function (before the callParent) :

this.title = this.myRecord.get('ID');

Upvotes: 2

Related Questions