2013-07-31 51 views
2

我有一个简单的组合框如下:组合框 - 在下拉列表中自动位置

    { 
        xtype: 'combobox', 
        id: 'prd-main-group', 
        fieldLabel: 'ANA MAL GRUBU', 
        inputWidth: 320, 
        labelWidth: 160, 
        labelAlign: 'right', 
        margin: '15 0 0 0', 
        fieldStyle: 'height: 26px; text-align: right; font-size: 12pt; color:#505050', 
        store: articleMain, 
        valueField: 'WHG', 
        displayField: 'WHG_BEZ', 
        queryMode: 'remote', 
        autoSelect: false, 
        selectOnFocus: true, 
        hideTrigger: true, 
        msgTarget: 'side', 
        triggerAction: 'all', 
        typeAhead: true, 
        minChars: 2, 
        listeners: { 
         select: function (combo, selection) { 
          articleBase.proxy.extraParams = {'maingroup': combo.getValue()}; 
          Ext.getCmp('prd-base-group').setDisabled(false); 
          Ext.getCmp('prd-base-group').getStore().removeAll(); 
          Ext.getCmp('prd-base-group').setValue(null); 
          Ext.getCmp('prd-sub-group').getStore().removeAll(); 
          Ext.getCmp('prd-sub-group').setValue(null); 
          articleBase.load(); 
         }, 
         focus: function(combo) { 
          combo.setValue(''); 
         } 
        } 
       }, 

当我输入两个或多个字符,组合框下拉列表中出现,显示值,但没有自动定位所选记录从下拉列表中选择。

正如你所看到的附加屏幕截图,完成的值,但下拉列表没有集中选定的记录!

enter image description here

我的问题是,当我们键入几个字符,在下拉列表中应自动改变基于给定的字符。

回答

1

没有Skirtle的巢穴我会做什么:)

我们应该设置autoLoad: true参数在store定义。之后,我们也应该设置queryModelocal。我知道这是没有意义的,但是当我们设置autoLoad时,只要商店创建就加载数据!

    { 

        xtype: 'combobox', 
        id: 'prd-main-group', 
        fieldLabel: 'ANA MAL GRUBU', 
        inputWidth: 320, 
        labelWidth: 160, 
        labelAlign: 'right', 
        margin: '15 0 0 0', 
        fieldStyle: 'height: 26px; text-align: right; font-size: 12pt; color:#505050', 
        store: articleMain, 
        valueField: 'WHG', 
        displayField: 'WHG_BEZ', 
        queryMode: 'local', 
        autoSelect: true, 
        forceSelection: true, 
        msgTarget: 'side', 
        triggerAction: 'all', 
        listeners: { 
         select: function (combo, selection) { 
          articleBase.proxy.extraParams = {'maingroup': combo.getValue()}; 
          Ext.getCmp('prd-base-group').setDisabled(false); 
          Ext.getCmp('prd-base-group').getStore().removeAll(); 
          Ext.getCmp('prd-base-group').setValue(null); 
          Ext.getCmp('prd-sub-group').getStore().removeAll(); 
          Ext.getCmp('prd-sub-group').setValue(null); 
          articleBase.load(); 
         }, 
         focus: function(combo) { 
          combo.setValue(''); 
         } 
        } 
       } 

而这里是商店的定义:

var articleMain = new Ext.data.JsonStore({ 
model: 'ArticleMainGroup', 
autoLoad: true, 
proxy: { 
    type: 'ajax', 
    url: '<?php echo base_url() ?>create/get_product_main_group', 
    reader: { 
     type: 'json', 
     root: 'articleMainGroup', 
     idProperty: 'ID' 
    } 
} 
}); 
0

您应该试试autoSelect: true

+0

我想什么都没有发生之前。 –

0

ForceSelection="true" + TypeAhead="true",它应该工作