Results 1 to 5 of 5

Thread: ComboBox value in a EditorGrid?

  1. #1
    Touch Premium Member
    Join Date
    Jul 2007
    Location
    Garland, Texas
    Posts
    46

    Question ComboBox value in a EditorGrid?

    How can I reference the value of a comboBox in an EditorGrid?

    Code:
    ...
    
    
    
    function getColumnModel() {
    	if(!columnModel) {
    		columnModel = new Ext.grid.ColumnModel(
    			[
    				{
    					header: 	'Cuisine',
    					width:		125,
    					sortable: 	true,
    					dataIndex: 	'cuisine_id',
    					editor: 	new Ext.grid.GridEditor(cbCuisine),
    					renderer:	function(value, p, record){
    						return record.data['cuisine_name'];
    					}
    				}
    			]
    		);
    	}
    	return columnModel;
    }
    
    function buildGrid() {	
    	gridForm = new Ext.BasicForm(
    		Ext.get("updategrid"),
    		{
    			
    		}
    	);
    		
    	grid = new Ext.grid.EditorGrid(
    		'mygrid',
    		{
    			ds: ds,
    			cm: getColumnModel(),
    			autoSizeColumns: false,
    			trackMouseOver: true,
    			selModel: new Ext.grid.RowSelectionModel({singleSelect:true})
    		}
    	);
    	
    ...
    }
    I believe this code snippet is enough to help with the answer - if it's too short let me know.

    Thanks in advance!

  2. #2
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618

    Default

    If I'm right (and I may well not be... ), in the config for the combo box, you should have:
    Code:
    name: "fieldname"
    This tells the grid, and the form if you use it with that, the name of the field. From there you should be able to get the value.

  3. #3
    Touch Premium Member
    Join Date
    Jul 2007
    Location
    Garland, Texas
    Posts
    46

    Default

    Thanks catacaustic!

    Let me give that a shot!

  4. #4

    Default

    Here is a combobox example:

    PHP Code:
    var combo = new Ext.form.ComboBox({
                
    storestore,
                
    displayField'name',
                
    readOnlytrue,
                
    valueField'value',
                
    loadingText'Loading data',
                
    triggerAction'all',
                
    mode'remote',
                
    emptyText:'Selecteer name',
                
    width:135          
    }); 
    displayField is the value that you see in the combobox
    valueField is the value of the selected field

    (in HTML it's: <option value="valueField">displayField</option>)

    to acces the values:

    combo.getRawValue() = value of displayField
    combo.getValue() = value of valueField

  5. #5
    Touch Premium Member
    Join Date
    Jul 2007
    Location
    Garland, Texas
    Posts
    46

    Thumbs up That's the stuff

    Perfecto!

    The .getValue() is exactly what I was looking for.

Posting Permissions

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