2015-03-05 5 views
0

я использую ExtJS 3.4по умолчанию в ExtJS комбинированном окне

Вот мой код:

Ext.onReady(function() { 
     var myPanel = new Ext.Panel({ 
      renderTo : document.body, 
      height : 500, 
      width : 1000, 
      title : 'Simple Panel', 
      html  : 'This is my content', 
      frame : true, 
      items: { 
      layout: 'form', 
      width: 200, 
      labelAlign: 'top', 
      style: 'margin-top: 5px;', 
      items: {   
       xtype: 'combo', 
       id: 'x', 
       width: 115, 
       listWidth: 115, 
       fieldLabel: '<b>My combo</b>', 
       labelStyle: 'font-size: 11px;', 
       style: 'margin-left:20px', 
       labelSeparator: '', 
       forceSelection: true, 
       value: 'A',  
       store: ['A', 'B', 'c'],     
       autoSelect: true      
      } 
    } 
     }); 

    }); 

Я хочу сделать «А» по ​​умолчанию ... сейчас он показывает только " а»в поле со списком ... и„B“и„с“отсутствуют (значит и отсутствуют в списке)

Пожалуйста, помогите

ответ

0

Вы не определяя магазин правильно или говорит комбо, который поля для использования в магазине.

Попробуйте код ниже

var myPanel = new Ext.Panel({ 
    renderTo: Ext.getBody(), 
    height: 500, 
    width: 1000, 
    title: 'Simple Panel', 
    html: 'This is my content', 
    frame: true, 
    items: { 
     layout: 'form', 
     width: 200, 
     labelAlign: 'top', 
     style: 'margin-top: 5px;', 
     items: { 
      xtype: 'combo', 
      id: 'x', 
      width: 115, 
      listWidth: 115, 
      fieldLabel: '<b>My combo</b>', 
      labelStyle: 'font-size: 11px;', 
      style: 'margin-left:20px', 
      labelSeparator: '', 
      forceSelection: true, 
      typeAhead: true, 
      triggerAction: 'all', 
      lazyRender:true, 
      mode: 'local', 
      value: 'A', 
      store: new Ext.data.ArrayStore({ 
       id: 0, 
       fields: [ 
        'myId', 
        'displayText' 
       ], 
       data: [['A', 'A'], ['B', 'B'], ['C', 'C']] 
      }), 
      valueField: 'myId', 
      displayField: 'displayText', 
      autoSelect: true 
     } 
    } 
}); 

Основные различия отметить:

mode: 'local', 
store: new Ext.data.ArrayStore({ 
      id: 0, 
      fields: [ 
       'myId', 
       'displayText' 
      ], 
      data: [['A', 'A'], ['B', 'B'], ['C', 'C']] 
     }), 
     valueField: 'myId', 
     displayField: 'displayText' 

Ссылка: ExtJs 3.4 Combo with Local Data