We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38181 ☆ A M B ☆
    • 26 Posts
    Hi,

    Been struggling with this one all day ... I know it will be a simple answer, but everything is when you know how!!

    I have created a CMP form which is displaying fine, coded as follows:

    ETClient.grid.ETClient = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            id: 'etclient-grid-etclient'
            ,url: ETClient.config.connectorUrl
            ,baseParams: {
                action: 'mgr/etclient/getClient'
                ,clientid:  7
            }
            ,save_action: 'mgr/etclient/updateFromGrid'
            ,fields: ['id','firstname','lastname','address1','address2','address3','town','county','postcode',
                'country','email','workphone','mobilephone','homephone','skype',
                'facebook','title','initials','housenamenumber','overseas','originatingsource',
                'passportnumber','passportcountry','dateofbirth','allowmailing','allowemail']
            ,paging: true
            ,autosave: true
            ,remoteSort: true
            ,anchor: '97%'
            ,autoExpandColumn: 'lastname'
            ,columns: [{
                header: _('id')
                ,dataIndex: 'id'
                ,sortable: true
                ,width: 10
                ,hidden: true
            },{
                header: _('clientfirstname')
                ,dataIndex: 'firstname'
                ,sortable: true
                ,width: 100
            },{
                header: _('clientlastname')
                ,dataIndex: 'lastname'
                ,sortable: true
                ,width: 100
                ,renderer: function(value, metaData, record) {
                    var hvName = record.get('lastname');
                    var hvID = record.get('id');
                    var syslogURL = "?a=82&action=view&clientid=" + hvID;
                    return "<a href='" + syslogURL + "'>"+hvName+"</a>";
                }
            },{
                header: _('clientaddress')
                ,dataIndex: 'address1'
                ,sortable: true
                ,width: 100
            },{
                header: _('clientaddress')
                ,dataIndex: 'address2'
                ,sortable: true
                ,width: 100
            },{
                header: _('clienttown')
                ,dataIndex: 'town'
                ,sortable: true
                ,width: 100
            },{
                header: _('clientcountry')
                ,dataIndex: 'country'
                ,sortable: true
                ,width: 100
            },{
                header: _('clienthphone')
                ,dataIndex: 'homephone'
                ,sortable: true
                ,width: 100
            }]
            ,tbar: [{
                xtype: 'textfield'
                ,id: 'etclient-search-filter'
                ,emptyText: _('clientsearch')
                ,listeners: {
                    'change': {fn:this.search,scope:this}
                    ,'render': {fn: function(cmp) {
                        new Ext.KeyMap(cmp.getEl(), {
                            key: Ext.EventObject.ENTER
                            ,fn: function() {
                                this.fireEvent('change',this);
                                this.blur();
                                return true;
                            }
                            ,scope: cmp
                        });
                    },scope:this}
                }
            },{
                text: _('clientcreate')
                ,handler: { xtype: 'etclient-window-etclient-create' ,blankValues: true }
            }]
        });
        ETClient.grid.ETClient.superclass.constructor.call(this,config)
    };
    Ext.extend(ETClient.grid.ETClient,MODx.grid.Grid,{
        search: function(tf,nv,ov) {
            var s = this.getStore();
            s.baseParams.query = tf.getValue();
            this.getBottomToolbar().changePage(1);
            this.refresh();
        }
        ,getMenu: function() {
            var m = [{
                text: _('update')
                ,handler: this.updateETClient
            }];
            this.addContextMenuItem(m);
            return true;
        }
        ,updateETClient: function(btn,e) {
            if (!this.updateETClientWindow) {
                this.updateETClientWindow = MODx.load({
                    xtype: 'etclient-window-etclient-update'
                    ,record: this.menu.record
                    ,listeners: {
                        'success': {fn:this.refresh,scope:this}
                    }
                });
            }
            this.updateETClientWindow.setValues(this.menu.record);
            this.updateETClientWindow.show(e.target);
        }
    });
    Ext.reg('etclient-grid-etclient',ETClient.grid.ETClient);


    You can see that, at the top, I have hard coded the clientid: 7 - this works fine, gets passed to the getClient.php file vie the connector and returns the result I want .....

    But I want to be able to set the clientid based on a parameter sent as part of the URL:

    For example:

    http://mysite/manager/?a=82&action=view&clientid=9


    How do I pass the clientid from URL parameter to the baseParams element of the cmp form code?

    Ta very much.
    [ed. note: [email protected] last edited this post 14 years, 7 months ago.]
      • 28215
      • 4,149 Posts
      You can use the JS object: MODx.request

      For example, if you want the GET param "clientid", you'd reference in JS:

      MODx.request.clientid
      
      ;
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 38181 ☆ A M B ☆
        • 26 Posts
        Phew .... many thanks as always ... solved it.

        Great.

        Cheers for now