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

    I’m having an category combobox in the tbar, in my grid page.

    The combobox definition:

    MyCmp.combo.CategoryList = function(config) {
        config = config || {};
        Ext.applyIf(config, {
            name: 'category',
    		hiddenName: 'category',
    		displayField: 'name',
    		valueField: 'id',
    		fields: ['id','name'],
    		forceSelection: true,
    		typeAhead: true,
    		editable: false,
    		allowBlank: false,
    		url: MyCmp.config.connector_url,
    		baseParams: {
                action: 'mgr/categories/getList',
    			combo: true
            }
        });
    	
        MyCmp.combo.CategoryList.superclass.constructor.call(this, config);
    };
    
    Ext.extend(MyCmp.combo.CategoryList, MODx.combo.ComboBox);
    Ext.reg('my-combo-categories', MyCmp.combo.CategoryList);


    The tbar code:

    tbar: [{
    	text: 'Create',
    	handler: {
    		xtype: 'my-window-create',
    		blankValues: true
    	}
    },{
    	xtype: 'tbfill'
    },{
    	xtype: 'my-combo-categories',
    	name: 'categories',
    	id: 'filter-category',
    	emptyText: 'Category',
    	value: MODx.request.category ? MODx.request.category : 1,
    	allowBlank: false,
    	width: 150,
    	listeners: {
    		'select': { fn: this.filterByCategory, scope:this }
    	}
    }]


    The create window code:

    MyCmp.window.CreateMessage = function(config) {
        config = config || {};
    	
        Ext.applyIf(config,{
    		title: 'Create message',
    		url: MyCmp.config.connector_url,
    		baseParams: {
    			action: 'mgr/messages/create'
    		},
    		fields: [{
    				xtype: 'textfield',
    				fieldLabel: 'Name',
    				name: 'name',
    				width: 200,
    				allowBlank: false
    			},{
    				xtype: 'textarea',
    				fieldLabel: 'Message',
    				name: 'message',
    				width: 200,
    				allowBlank: false
    			}
    		]
        });
    	
        MyCmp.window.CreateMessage.superclass.constructor.call(this, config);
    };
    
    Ext.extend(MyCmp.window.CreateMessage, MODx.Window);
    Ext.reg('message-window-create', MyCmp.window.CreateMessage);


    Now I have binded a window to the create button with a simple form, with a name and message field in it (wicht is already working fine). But I want to link the new record to the selected category in the combobox. How do I get the ’id’ value of the combobox hidden send by my create window to the create-processor script?

    Hope you understand and could help me out! Thanks in advance

    Regards, Bert
      MODX Ambassador (NL) & Professional MODX developer
      Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
      MODX e-commerce solution SimpleCart