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

    http://pastebin.com/XWUhXPwN

    OR

    Bookit.grid.Items = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            id: 'bookit-grid-items'
            ,url: Bookit.config.connectorUrl
            ,baseParams: { action: 'mgr/bookit/items/getItems' }
            ,fields: ['id','name', 'active', 'openschedule', 'pricing', 'pricing_label', 'openschedule_label']
            ,save_action: 'mgr/bookit/items/updateFromGrid'
            ,autosave: true
            ,paging: true
            ,remoteSort: true
            ,enableDragDrop: false
            ,anchor: '97%'
            ,autoExpandColumn: 'name'
    		,getMenu: function() {
    			var m = [{
    				text: _('bookit.set_pricing')
    				,handler: this.setPricing
    			}];
    			this.addContextMenuItem(m);
    			return true;
    		}
    
            ,columns: [{
                header: _('bookit.item_name')
                ,dataIndex: 'name'
                ,editor: { xtype: 'textfield' }
                ,sortable: false
            },{
            	header: _('bookit.openschedule')
            	,dataIndex: 'openschedule_label'    	
            },{
            	header: _('bookit.item_pricing')
            	,dataIndex: 'pricing_label'
            },{
            	header: _('bookit.item_active')
            	,dataIndex: 'active'
            	,editor: { xtype: 'modx-combo-boolean', renderer: true}
            }]
        });
        Bookit.grid.Items.superclass.constructor.call(this,config)
    };
    Ext.extend(Bookit.grid.Items,MODx.grid.Grid, {
    	setPricing: function(btn,e) {
    	    if (!this.setPricingWindow) {
    	        this.setPricingWindow = MODx.load({
    	            xtype: 'bookit-window-setpricing'
    	            ,record: this.menu.record
    	            ,listeners: {
    	                'success': {fn:this.refresh,scope:this}
    	            }
    	        });
    	    }else{
    	    	this.setPricingWindow.setValues(this.menu.record);
    	    }
    	    
    	    this.setPricingWindow.show(e.target);
    	}
    
    });
    Ext.reg('bookit-grid-items',Bookit.grid.Items);
    
    
    Bookit.window.SetPricing = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            title: _('bookit.set_pricing')
            ,url: Bookit.config.connectorUrl
            ,baseParams: {
                action: 'mgr/bookit/items/setPricing'
            }
            ,fields: [{
                xtype: 'hidden'
                ,name: 'id'
            },{
                xtype: 'bookit-extra-combo-pricing'
                ,baseParams: { action: 'mgr/bookit/extra/getPricing', itemid: config.record.id }
                ,fieldLabel: _('bookit.item_pricing')
                ,name: 'pricing'
                ,width: 300
            }]
        });
        Bookit.window.SetPricing.superclass.constructor.call(this,config);
    };
    Ext.extend(Bookit.window.SetPricing,MODx.Window);
    Ext.reg('bookit-window-setpricing',Bookit.window.SetPricing);
    
    


    how is it possible to update variable config.record.id on line 77? When I right-click row in grid and select "set_roicing" I have same id for all rows.

    Got idea - destroy thw window and create again new for every right-click and select this item, but I didn't find how to destroy it :-/

    any idea please? [ed. note: TheBoxer last edited this post 14 years, 11 months ago.]
      --
      John
      @theboxer
      • 29661
      • 116 Posts
      ok, I solved this by changing button function - cancel button calls close function instead of hide.

      ,buttons: [{
                  text: config.cancelBtnText || _('cancel')
                  ,scope: this
                  ,handler: function() { this.close(); }
              }]
        --
        John
        @theboxer