Combobox 在ExtJS中显示为输入框的组合框

Combobox 在ExtJS中显示为输入框的组合框,combobox,extjs4,Combobox,Extjs4,我是ExtJS新手,我试图在面板内显示combobox,但在添加下面的代码时,Combo项的inputbox出现了。 这是密码 { xtype: 'combobox', fieldLabel: 'Rating', name: 'rating', store: [['1', '4']], id: 'test', forceSelection: false, editable: true, typeAhead: true, se

我是ExtJS新手,我试图在面板内显示combobox,但在添加下面的代码时,Combo项的inputbox出现了。 这是密码

{
    xtype: 'combobox',
    fieldLabel: 'Rating',
    name: 'rating',
    store: [['1', '4']],
    id: 'test',
    forceSelection: false,
    editable: true,
    typeAhead: true,
    selectOnFocus: true
},

谢谢你的回答,但还是不行,我不知道哪里出了错。 请帮助我,我已经为此浪费了一天的时间

<html>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/ext-all.css" />
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/js/ext-base.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/js/ext-all.js"></script>


<title>Insert title here</title>
<head>
<title>Search Box Example 1</title>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<!-- CSS styles for standard search box -->
</head>
<body>
<script type="text/javascript">
/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
// some data used in the examples

/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally

    var fs = new Ext.FormPanel({
        frame: true,
        title:'XML Form',
        labelAlign: 'right',
        labelWidth: 85,
        width:340,
        waitMsgTarget: true,

        // configure how to read the XML Data
        // reusable eror reader class defined at the end of this file
        items: [
            new Ext.form.FieldSet({
                title: 'Contact Information',
                autoHeight: true,
                defaultType: 'textfield',
                items: [{
                        fieldLabel: 'First Name',
                        name: 'first',
                        width:190
                    }, {
                        fieldLabel: 'Last Name',
                        name: 'last',
                        width:190
                    }, {
                        fieldLabel: 'Company',
                        name: 'company',
                        width:190
                    }, {
                        fieldLabel: 'Email',
                        name: 'email',
                        vtype:'email',
                        width:190
                    },

                    new Ext.form.ComboBox({
                        fieldLabel: 'State',
                        hiddenName:'state',
                        store: ['1', '4'],
                        valueField:'abbr',
                        displayField:'state',
                        typeAhead: true,
                        mode: 'local',
                        triggerAction: 'all',
                        emptyText:'Select a state...',
                        selectOnFocus:true,
                        width:190
                    }),

                    new Ext.form.DateField({
                        fieldLabel: 'Date of Birth',
                        name: 'dob',
                        width:190,
                        allowBlank:false
                    })
                ]
            })
        ]
    });

    // simple button add


    // explicit add
      fs.render('form-ct');

    fs.on({
        actioncomplete: function(form, action){
            if(action.type == 'load'){
                submit.enable();
            }
        }
    });

});

</script> 

<div id="form-ct"></div>

</body>
</html>

在此处插入标题
搜索框示例1
/*!
*ExtJS库3.0.0
*版权所有(c)2006-2009 Ext JS有限责任公司
* licensing@extjs.com
* http://www.extjs.com/license
*/
//示例中使用的一些数据
/*!
*ExtJS库3.0.0
*版权所有(c)2006-2009 Ext JS有限责任公司
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.onReady(函数(){
Ext.QuickTips.init();
//全局打开字段旁边的验证错误
var fs=新的Ext.FormPanel({
框架:对,
标题:“XML表单”,
labelAlign:'对',
标签宽度:85,
宽度:340,
waitMsgTarget:是的,
//配置如何读取XML数据
//在此文件末尾定义的可重用eror读取器类
项目:[
新的Ext.form.FieldSet({
标题:“联系信息”,
自动高度:正确,
defaultType:'textfield',
项目:[{
fieldLabel:“名字”,
姓名:'第一',
宽度:190
}, {
fieldLabel:“姓氏”,
姓名:'最后',
宽度:190
}, {
fieldLabel:“公司”,
名称:'公司',
宽度:190
}, {
fieldLabel:“电子邮件”,
名称:'电子邮件',
vtype:“电子邮件”,
宽度:190
},
新的Ext.form.ComboBox({
字段标签:“状态”,
hiddenName:“state”,
商店:['1','4'],
值字段:'abbr',
显示字段:'state',
是的,
模式:“本地”,
触发动作:“全部”,
emptyText:“选择一个状态…”,
selectOnFocus:true,
宽度:190
}),
新的Ext.form.DateField({
fieldLabel:“出生日期”,
名称:“dob”,
宽度:190,
allowBlank:false
})
]
})
]
});
//简单按钮添加
//显式加法
财政司司长提交(“表格-ct”);
财政司司长({
actioncomplete:功能(表单、操作){
如果(action.type=='load'){
submit.enable();
}
}
});
});

您是
存储
数据的数组
是双重嵌套的,而应该是
['1','4']
。所以只有一个选项显示