2013-07-04 45 views
0

我創建了一個組合框並附加了一個數組來存儲。我想要的是,使用可以從列表中選擇,或者也可以輸入自定義文本。我搜索到,可以通過forceSelection = false來實現,我閱讀了文檔,發現forceSelection默認是false,因爲我使用的是sencha架構師,所以我不能明確地設置配置。所以下面是我所做的配置。但只要我按Tab或輸入組合框中輸入的文本不再存在。Extjs Combobox:組合框上的forceSelection false不起作用

{ 
xtype: 'fieldcontainer',          
id: 'internetmessager', 
autoDestroy: false, 
layout: { 
    align: 'stretch', 
    type: 'hbox' 
}, 
items: [ 
    { 
     xtype: 'combobox', 
     flex: 1, 
     margin: '0 10 0 0', 
     name: 'label', 
     autoSelect: false, 
     queryMode: 'local', 
     store: [ 
      'Home', 
      'Work', 
      'Personal' 
     ], 
     typeAhead: true 
    }, 
    { 
     xtype: 'textfield', 
     flex: 2, 
     name: 'value', 
     emptyText: 'IM' 
    } 
] 
} 

感謝, 阿里阿巴斯

回答

0

我認爲這是煎茶建築師2.2.2中的錯誤,那就是forceSelection'的默認值是true,但文件說,這是假的。並且,架構師不會爲您提供通過假設「forceSelection」屬性爲false來構建'forceSelection'假b/c的方法。如果我錯了,那我得到正確的答案。我做的解決方法是在arhitect配置面板中使用'Process Confg'。其中新增的processLabel功能

{ 
    xtype: 'fieldcontainer', 
    id: 'internetmessager', 
    autoDestroy: false, 
    layout: { 
     align: 'stretch', 
     type: 'hbox' 
    }, 
    items: [ 
     me.processLabel({ 
      xtype: 'combobox', 
      flex: 1, 
      margin: '0 10 0 0', 
      name: 'label', 
      store: [ 
       'Home', 
       'Work', 
       'Personal' 
      ], 
      valueField: 'text' 
     }), 
     { 
      xtype: 'textfield', 
      flex: 2, 
      name: 'value', 
      emptyText: 'IM' 
     } 
    ] 
} 

而且在processLabel功能我做了forceSelection屬性顯式假。

processLabel: function(config) {   
    config.forceSelection = false; 
    return config; 
} 
0

[編輯] 哦男人......對不起......我 重讀againg你的問題後,我意識到你正在使用煎茶建築師 [ /編輯]

我不確定,如果我的理解正確... 我做了什麼: 寫入組合框或從其商店中選擇一個值。 離開(模糊監聽器)組合框時,實際值將被設置到文本字段中。 BTW:ITEMID的將是不錯的使用(恕我直言)

items: [ 
{ 
    xtype: 'fieldcontainer', 
    id: 'internetmessager', 
    autoDestroy: false, 
    layout: { 
     align: 'stretch', 
     type: 'hbox' 
    }, 
    items: [ 
     { 
      xtype: 'combobox', 
      flex: 1, 
      margin: '0 10 0 0', 
      name: 'label', 
      autoSelect: false, 
      queryMode: 'local', 
      store: [ 
       'Home', 
       'Work', 
       'Personal' 
      ], 
      typeAhead: true, 
      listeners: { 
       blur: function (combo) { 
        Ext.ComponentQuery.query('[name=value]')[0].setValue(combo.getValue()); 
       } 
      } 
     }, 
     { 
      xtype: 'textfield', 
      flex: 2, 
      name: 'value', 
      emptyText: 'IM' 
     } 
    ] 
} 
+0

不,我認爲我沒有正確解釋這件事。我真正想要的是用戶可以鍵入不存在於存儲陣列中的自定義標籤。意味着用戶可以在組合框中鍵入'Office',並且該值在用戶選項卡到其他字段後保留。實際發生的是,當我在組合框中鍵入「辦公室」,然後按組合框中的選項卡值變空。 –