Javascript ExtJs4-自动完成组合框不显示空文本

Javascript ExtJs4-自动完成组合框不显示空文本,javascript,extjs,autocomplete,combobox,extjs4,Javascript,Extjs,Autocomplete,Combobox,Extjs4,我有一个组合框,配置如下 { fieldLabel:'Service', xtype:'combo', displayField: 'srvcDesc', store: storeServiceCodeVar, valueField:'srvcCD', id:'serviceCodeId', name:'serviceCodeName', queryMode: 'remote', queryDelay:100, ty

我有一个组合框,配置如下

{
    fieldLabel:'Service',
    xtype:'combo',
    displayField: 'srvcDesc',
    store: storeServiceCodeVar,
    valueField:'srvcCD',
    id:'serviceCodeId',
    name:'serviceCodeName',
    queryMode: 'remote',
    queryDelay:100,
    typeAhead: true,
    minChars:0,
    hideTrigger:true,
    forceSelection:true,
    maxHeight:23,
    deferEmptyText:false,
    autoSelect:true,
    fieldStyle:'text-transform:uppercase',
    listConfig: {
        loadingText: 'Loading...',
        // Custom rendering template for each item
        getInnerTpl: function() {
            return '<table width="200px"><tr><td height="5"></td></tr><tr valign="top"><td>Code:{srvcCD}</td></tr><tr><td height="2"></td></tr><tr valign="top"><td>Description:{srvcDesc}</td></tr><tr><td height="5"></td></tr></table>';
        },
        emptyText:'No Values Found'
    }
}
{
fieldLabel:“服务”,
xtype:“组合”,
显示字段:“srvcDesc”,
存储:storeServiceCodeVar,
值字段:'srvcCD',
id:'serviceCodeId',
名称:'serviceCodeName',
queryMode:'远程',
查询显示:100,
是的,
明查斯:0,
希德崔格:没错,
选择:对,
最大高度:23,
deferEmptyText:false,
自动选择:正确,
fieldStyle:“文本转换:大写”,
列表配置:{
loadingText:“正在加载…”,
//每个项目的自定义渲染模板
getInnerTpl:函数(){
返回'Code:{srvcCD}说明:{srvcDesc}';
},
emptyText:“未找到值”
}
}
问题是,当没有从服务器返回数据时,emptyText(有值-找不到值)会显示一毫秒并熄灭。如果被解雇,我想让它一直呆在那里直到下一个查询。这怎么可能。我试过使用deferEmptyText,但没有成功

有人能解释一下吗。我使用的是ExtJS4,在IE9和Mozilla中的行为是相同的


提前感谢。

从源代码开始,似乎没有任何引用用于确定是否将元素高度设置为零以外的数字

我最终覆盖了Ext.form.field.ComboBox从Ext.form.field.Picker继承的
alignPicker()
函数,并添加了对
listConfig.emptyText
的检查

Ext.override(Ext.form.field.ComboBox, {

    alignPicker: function() {
        var picker, height;

        if (this.isExpanded) {
            // Get the picker component.
            picker = this.getPicker();

            if (this.matchFieldWidth) {
                // Set the default height to null, since we don't 
                // automatically want to have the height changed.
                height = null;

                // If our store exists, but the count is zero
                // and we've got no emptyText defined...
                if (picker.store && 
                    picker.store.getCount() === 0 && 
                    Ext.isEmpty(this.listConfig.emptyText)) {
                    // ...we set the height to zero. 
                    height = 0;
                }

                // Set the size of the picker component.
                picker.setSize(this.bodyEl.getWidth(), height);
            }

            if (picker.isFloating()) {
                this.doAlign();
            }
        }
    }

});

希望这有帮助

这里有一句警告的话。我在ExtJS4-0-6上,现在似乎在
Ext.form.field.ComboBox
中有了一些代码,它不再仅仅依赖于从
Ext.field.form.Picker
继承方法

因此,上面的代码现在应该直接覆盖
Ext.field.form.Picker
中的代码,而不是
组合框中的代码


但不可否认,希望Sencha能很快在4.1中解决这个问题。

也在努力解决这个问题;看起来emptyText值正按预期添加到DOM中,但当服务器未返回任何记录时,包含元素的高度将设置为零。目前正在查看ExtJS4源代码,以获得一些灵感……嘿,丹尼尔,谢谢分享这篇文章。太棒了。对我来说,当独立创建组合框时,emptyText工作得非常好,但当与其余应用程序的代码合并时,它会停止显示。我还试图找到影响emptyText行为的部分。如果有什么有用的,我会在这里分享。再次感谢您的时间。嗨,我不确定我是否理解您的问题。“独立创建”是什么意思?您现有的应用程序是什么?您上面描述的combobox的emptyText问题是ExtJS4中的一个已知错误(请参阅),目前这种攻击应该可以解决您的问题。谢谢您的帖子。提到“独立创建”,我的意思是,如果我创建了一个测试页面,并包含extjs库和emptyText测试,那么它对我来说就可以了。但当我把它包括在我的应用程序中时,它就不起作用了。我在进一步调查时发现了这一点,并意识到这可能是由于我们在应用程序中修改了某些内容所致。但看看你所提供的,整个情况看起来像是一个混乱。不过,谢谢你分享这篇文章。