We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31640
    • 100 Posts
    Hi,

    I am developping a component to manage soccer games.
    Starting point is a data grid with al the games.
    Then it is possible to open a window (with 3 tabs) with the game info.

    One of the 3 tabs is another grid with some detail info.
    Now i am trying to pass the game id from the window to the grid in the thirth tab of the window

    The window with 3 tabs:
    vSoccer.window.UpdateWedstrijd = function(config) {
        config = config || {};
        this.ident = config.ident || 'vsoccer-meuitem'+Ext.id();
        Ext.applyIf(config,{
            title: _('vsoccer.wedstrijd_update')
            ,id: this.ident
            ,width: 650
            ,url: vSoccer.config.connector_url
            ,action: 'mgr/wedstrijden/update'
            ,fields: [{
                xtype: 'modx-tabs'
                ,deferredRender: false
                ,forceLayout: true
                ,width: '98%'
                ,borderStyle: 'padding: 10px 10px 10px 10px;'
                ,border: true
                ,defaults: {
                    border: false
                    ,labelWidth: 100
                    ,autoHeight: true
                    ,bodyStyle: 'padding: 5px 8px 5px 5px;'
                    ,layout: 'form'
                    ,deferredRender: false
                    ,forceLayout: true
                }
                ,items: [{
                    title: _('vsoccer.wedstrijd_info')
                    ,items: [{
                        xtype: 'hidden'
                        ,id: 'update_wedstrijd_id'
                        ,name: 'wedstrijd_id'
                    },{
                        xtype: 'hidden'
                        ,id: 'update_wedstrijd_seizoen_id'
                        ,name: 'wedstrijd_seizoen_id'
                    },{
                        xtype: 'datefield'
                        ,fieldLabel: _('vsoccer.wedstrijd_dag')
                        ,name: 'wedstrijd_dag'
                        ,id: this.ident+'-wedstrijd_dag'
                        ,anchor: '100%'
                        ,format: 'd-m-Y'
                    },{
                        xtype: 'timefield'
                        ,fieldLabel: _('vsoccer.wedstrijd_uur')
                        ,name: 'wedstrijd_uur'
                        ,id: this.ident+'-wedstrijd_uur'
                        ,anchor: '100%'
                        ,increment: 15
                        ,format: 'G:i:s'
                        ,minValue:'08:00'
                        ,maxValue:'22:00'
                    },{ xtype: 'compositefield',
                        fieldLabel: _('vsoccer.wedstrijd_ploeg'),
                        combineErrors: false,
                        items: [{
                            xtype: 'textfield'
                            ,fieldLabel: _('vsoccer.wedstrijd_ploeg_thuis')
                            ,name: 'wedstrijd_ploeg_thuis'
                            ,id: this.ident+'-wedstrijd_ploeg_thuis'
                            //,anchor: '100%'
                            //,width: 250
                            ,allowBlank: false
                            ,readOnly: true
                        },{
                            xtype: 'textfield'
                            ,fieldLabel: _('vsoccer.wedstrijd_ploeg_uit')
                            ,name: 'wedstrijd_ploeg_uit'
                            ,id: this.ident+'-wedstrijd_ploeg_uit'
                            //,anchor: '100%'
                            //,width: 150
                            ,allowBlank: false
                            ,readOnly: true
                        }]
                    },{ xtype: 'compositefield',
                        fieldLabel: _('vsoccer.wedstrijd_doelpunten'),
                        combineErrors: false,
                        items: [{
                            xtype: 'numberfield'
                            ,fieldLabel: _('vsoccer.wedstrijd_doelpunten_thuis')
                            ,name: 'wedstrijd_doelpunten_thuis'
                            ,id: this.ident+'-wedstrijd_doelpunten_thuis'
                            ,anchor: '100%'
                        },{
                            xtype: 'numberfield'
                            ,fieldLabel: _('vsoccer.wedstrijd_doelpunten_uit')
                            ,name: 'wedstrijd_doelpunten_uit'
                            ,id: this.ident+'-wedstrijd_doelpunten_uit'
                            ,anchor: '100%'
                        }]
                    },{
                        xtype: 'combo-boolean'
                        ,renderer: 'boolean'
                        ,value: 1
                        ,fieldLabel: _('vsoccer.wedstrijd_forfait')
                        ,name: 'wedstrijd_forfait'
                        ,allowBlank: false
                    }]
                },{
                    title:  _('vsoccer.wedstrijd_verslag')
                    ,items: [{
                        xtype: 'htmleditor'
                        ,fieldLabel: _('vsoccer.wedstrijd_matchverslag')
                        ,name: 'wedstrijd_matchverslag'
                        ,id: this.ident+'-wedstrijd_matchverslag'
                        ,anchor: '100%'
                        ,allowBlank: true
                        ,enableSourceEdit: true
                        ,height: 300
                    }]
                },{
                    title:  _('vsoccer.wedstrijd_data')
                    ,items: [{
                        xtype: 'vsoccer-grid-wedstrijd-data'
                        ,id: this.ident+'-wedstrijd_grid-wedstrijd-data'
                        ,anchor: '100%'
                        //,allowBlank: true
                        //,enableSourceEdit: true
                        ,height: 300
                     }]
                }
                ]
            }]
    
        });
        vSoccer.window.UpdateWedstrijd.superclass.constructor.call(this,config);
    };
    Ext.extend(vSoccer.window.UpdateWedstrijd,MODx.Window);
    Ext.reg('vsoccer-window-wedstrijd-update',vSoccer.window.UpdateWedstrijd);
    


    The grid with the game data in the thirth tab.
    Now i set the webstrijd id to 1593 but this should be dynamic

    vSoccer.grid.WedstrijdData = function(config) {
        config = config || {};
        config.wedstrijdid = 1593;// Ext.getCmp('update_wedstrijd_id').getValue();
        Ext.applyIf(config,{
            id: 'vsoccer-grid-wedstrijd-data'
            ,url: vSoccer.config.connector_url
            ,baseParams: {
                action: 'mgr/matchdata/getlist'
                ,wedstrijdid: config.wedstrijdid
            }
            ,fields: ['wedstrijd_data_id', 'speler_voornaam', 'speler_achternaam', 'wedstrijd_data_value', 'data_type_naam']
            ,autoHeight: true
            ,paging: true
            ,remoteSort: true
            ,pageSize: 10
            ,sortBy: 'wedstrijd_data_id'
            ,sortDir: 'ASC'
            ,columns: [{
                header: _('vsoccer.id')
                ,dataIndex: 'wedstrijd_data_id'
                ,width: 30
                ,hidden: true
            },{
                header: _('vsoccer.voornaam')
                ,dataIndex: 'speler_voornaam'
                ,width: 50
            },{
                header: _('vsoccer.achternaam')
                ,dataIndex: 'speler_achternaam'
                ,width: 100
            },{
                header: _('vsoccer.wedstrijd_data_type')
                ,dataIndex: 'data_type_naam'
                ,width: 70
            },{
                header: _('vsoccer.wedstrijd_data_aantal')
                ,dataIndex: 'wedstrijd_data_value'
                ,width: 30
            }]
            ,tbar: [{
                text: _('vsoccer.wedstrijd_data_create')
                ,handler: this.createWedstrijdData
                ,scope: this
            }]
        });
        vSoccer.grid.WedstrijdData.superclass.constructor.call(this,config);
    };
    


    Any help would be appreciated because i am looking for hours without finding a solution...
      • 39194
      • 149 Posts
      So, just pass your id into window constructor while creating your window.
        • 31640
        • 100 Posts
        How do i pass this into the window???
        The code i am having to create the window is:

            ,createWedstrijd: function(btn,e) {
                if (!this.windows.createWedstrijd) {
                    this.windows.createWedstrijd = MODx.load({
                        xtype: 'vsoccer-window-wedstrijd-create'
                        ,listeners: {
                            'success': {fn:function() { this.refresh(); },scope:this}
                        }
                    });
                }
                this.windows.createWedstrijd.fp.getForm().reset();
                this.windows.createWedstrijd.show(e.target);
            }
        


        And if i pass this in, how i access this variable?
        I am doing my best with extjs but it is not that easy smiley
          • 39194
          • 149 Posts
          The simplest way is to recreate windows:

          ,createWedstrijd: function(btn,e) {
              this.windows.createWedstrijd = MODx.load({
                  xtype: 'vsoccer-window-wedstrijd-create'
                  ,wedstrijdid: 'your_id'
                  ,listeners: {
                      'success': {fn:function() { this.refresh(); },scope:this}
                      ,'hide':{fn:function() {this.destroy();},scope:this}
                  }
              });
              this.windows.createWedstrijd.show(e.target);
          }
            • 31640
            • 100 Posts
            Ok this is new for me but this is great info...

            Just one last question. How can i access that variable?
            Is it available in the config value?

            vSoccer.grid.WedstrijdData = function(config) {
                config = config || {};
                config.wedstrijdid = 1593;
                Ext.applyIf(config,{
                    id: 'vsoccer-grid-wedstrijd-data'
                    ,url: vSoccer.config.connector_url
                    ,baseParams: {
                        action: 'mgr/matchdata/getlist'
                        ,wedstrijdid: config.wedstrijdid
                    }
                    ,fields: ['wedstrijd_data_id', 'speler_voornaam', 'speler_achternaam', 'wedstrijd_data_value', 'data_type_naam']
                    ,autoHeight: true
                    ,paging: true
                    ,remoteSort: true
                    ,pageSize: 10
                    ,sortBy: 'wedstrijd_data_id'
                    ,sortDir: 'ASC'
                    ,columns: [{
                        header: _('vsoccer.id')
                        ,dataIndex: 'wedstrijd_data_id'
                        ,width: 30
                        ,hidden: true
                    },{
                        header: _('vsoccer.voornaam')
                        ,dataIndex: 'speler_voornaam'
                        ,width: 50
                    }]
                    ,tbar: [{
                        text: _('vsoccer.wedstrijd_data_create')
                        ,handler: this.createWedstrijdData
                        ,scope: this
                    }]
                });
                vSoccer.grid.WedstrijdData.superclass.constructor.call(this,config);
            };