2011-12-02 2 views
0

나는 다음과 같은 배열과 콤보를 만들 :의 ExtJS 콤보는 배열

var operators = new Array(">=",">","=~","","!=","=","<","<="); 

문제는 내가 comboxbox의 기본 값으로 첫 번째 요소 (때로는 마지막 요소를) 좋아하는 것입니다. 성공적으로이 작업을 수행하는 방법을 찾지 못했습니다.

감사합니다. 중복 될 경우 대단히 죄송합니다.

편집

var ops = new Array(">=",">","=~","","!=","=","<","<="); 
var operators = new Ext.data.ArrayStore({ id: 0, fields: [ 'value' ], data: ops }); 

Ext.getCmp('variablesAttributesPanel').add({xtype: 'combo',  id: variables[j].getTitle() + 'MinCombo', mode: 'local', valueField: 'value', displayField: 'value', store: operators, width: 50, x: 240, y: (j * 20 + 19), editable: false, allowBlank: false}); 

이 드롭 다운 목록>, =,!의 옵션을 만들고, <

어떤 아이디어가?

답변

3

확인 triggerAction이

triggerAction : 'all'

var operators = new Array(">=",">","=~","x","!=","=","<","<="); 

var test1 = new Ext.form.ComboBox({ 
    height:100, 
    width:100, 
    store: operators 
}); 

var test2 = new Ext.form.ComboBox({ 
    height:100, 
    width:100, 
    triggerAction: 'all', 
    store: operators 
}); 

var win=new Ext.Window({ 
    renderTo:Ext.getBody(), 
    items:[test1,test2], 
    height:300, 
    width:300, 
    title:'comboWin' 
}).show(); 

test1.setValue(operators[1]); 
test2.setValue(operators[2]); 
0

콤보 박스의 setValue 메소드를 사용하십시오.

comboBox.setValue(operators[0]); 
+0

이 보인다 콤보 상자 설정에 설정되어 있는지 확인 : 그냥 배열 값에 전달할 수 있습니다이 경우, 디스플레이와 값이 동일하다 그렇게 할 때 운영자 [0]만이 목록에 있습니다. – gberg927

+0

콤보 상자 선언에서 배열을 저장소의 '데이터'요소로 지정해야합니다. var combo = new Ext.form.ComboBox ({ xtype : 'combo', 모드 : 'local', 가기 : 새로운 Ext.data.ArrayStore ({ ID : 0 필드 : '값' ] 데이터 : 연산자 }) valueField '값' displayField '값'} ); – hspain

+0

내 수정 사항을 확인할 수 있습니까? 난 문제가 생겨난 것 같았 어 – gberg927