Results 1 to 5 of 5

Thread: change combobox editor in grid

  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    232
    Vote Rating
    2
      0  

    Default change combobox editor in grid

    I've got a grid and a radiogroup on a toolbar.
    Immagine.png


    When I try to change one option of the radiogroup I want to change the properties of combobox of the column.
    It works only first time. Second time that I try to change an options of radiogroup the combobox within the row doesn't change.
    Example:
    Code:
    if(myOption=='F'){		
    	Ext.getCmp('myGrid').columns[0].editor={
    		xtype: 'combobox',
    		store: 'store1',
    		queryMode: 'local',
    		editable: false,
    		displayField: 'myField',
    		valueField: 'myValue',
    		triggerAction: 'all',
    		typeAhead: true,
    		minChars: 1,
    		matchFieldWidth: false,
    		allowBlank: false,
    		forceSelection: true,
    		listConfig: {
    			width: 300,
    			heigth: 200,
    			loadMask: false,
    			emptyText: 'Nessun record trovato'
    		}
    	};	
    }else{
    	Ext.getCmp('myGrid').columns[0].editor= {
    		xtype: 'combobox',
    		store: 'store2',
    		queryMode: 'remote',
    		editable: true,
    		displayField: 'valore',
    		valueField: 'codice',
    		queryParam: 'valore',
    		pageSize: 10,
    		hideTrigger: true,
    		triggerAction: 'all',
    		typeAhead: true,
    		minChars: 1,
    		matchFieldWidth: false,
    		allowBlank: false,
    		forceSelection: true,
    		listConfig: {
    			width: 300,
    			heigth: 200,
    			loadMask: false,
    			emptyText: 'Nessun record trovato'
    		},
    		listeners: {
    			beforequery: function(queryEvent){
    				if (!queryEvent.query)
    					return false;
    				}		
    		}
    	};
    }
    Last edited by scottmartin; 21 Jul 2012 at 5:10 PM. Reason: Please format your code!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,389
    Vote Rating
    497
      0  

    Default

    You could use the following:

    Code:
    beforeedit: function(ed, e, opts){
        var field;
        if(myOption == 'F'){
            // specify your editor here; 
            // using your xtype: 'mycombobox' or create
            field = { xtype: 'textfield' }; 
        } else {
            // specify other xtype: 'myothercombobox'
            field = { xtype: 'numberfield' }; 
        }
        // set the editor       
        ed.grid.columns[ed.colIdx].setEditor(field);
    }
    Scott.
    Last edited by scottmartin; 23 Jul 2012 at 5:19 AM. Reason: fixed params

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    232
    Vote Rating
    2
      0  

    Default

    Thanks for reply me.
    I used your code but I've got an error. "column.getEditor is not a function"
    I use Sencha Architect and in beforeedit I've got the following parameters:

    beforeedit: function(editor,e,options){
    }

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,389
    Vote Rating
    497
      0  

    Default

    My mistake.. cut/paste error... updated code for all params.

    Scott.

  5. #5
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    232
    Vote Rating
    2
      0  

    Default

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •