Results 1 to 4 of 4

Thread: why combox can't show displayfield on editorgrid

  1. #1

    Default why combox can't show displayfield on editorgrid

    test.JPG

    Question?
    help me,thanks

    When I get focus in cell,it will show displayfield value '业务一部', lost focus it will show value field '003',
    I want to get and lost always show displayfield value '业务一部'.
    (2)But when i update data,I will use value field as hidden value. display field only show.

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

    Default

    ComboBox editors in EditorGridPanels return the valueField value to the cell, not the displayField. That's the biggest problem with ComboBox's in EditorGridPanels that there is so far, and the only answer to it is to use a custom renderer with that column that can get the displayField value from the data store that is attached to the ComboBox. It's a bit of a long-way-around trip to get what should be easy, but this is one of those things that doesn't seem to have had to much thought put into it by the developers so far unfortunately.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  3. #3

    Default

    Its a bit of coding, but is easy to understand

    Code:
    //Combo Renderer
    comboRenderer= function(value) {
    	var record = yourComboName.store.getById(value);
    	return record ? record.get('text') : '';
    };
    
    //Combo Definition
    var yourComboName= new Ext.form.ComboBox({
    	typeAhead: true,
    	triggerAction: 'all',
    	transform:'yourHtmlSelectID',
    	lazyRender:true,
    	listClass: 'x-combo-list-small',					
    	displayField: 'text',
    	valueField: 'value',
            id: 'value'
    });
    
    //Combo Column
    var comboColumn = {
    	header: 'yourHeader',
    	dataIndex: 'yourDataIndex',
    	width: 150,	
    	renderer: comboRenderer,
    	editor: yourComboName
    };

  4. #4

    Thumbs up

    Ha! I had exactly the same question. Thank you!

Posting Permissions

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