Extjs组合默认值?

时间:2013-06-25 08:33:04

标签: extjs combobox

                               {
                                            xtype:'combo',
                    name : 'policyId',
                    fieldLabel : 'policyTyep',
                    padding : 'padding-left: 20%',
                    displayField : 'analysisName',
                    valueField : 'analysisId',
                    queryMode : 'local',
                    //value:-1,
                    value: {analysisName:'Select..',
                            analysisId:0},
                    store : policyDetailTypeStore
                }
                       If I the policyDetailTypeStore is loaded ,but have no data.

然后我想在combox中显示“Select ...”。我还将值配置为代码,但根本无法工作..

2 个答案:

答案 0 :(得分:8)

只需'选择'就足够了价值配置(值:'选择...')

请参阅示例代码。

// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        //{"abbr":"AL", "name":"Alabama"},
        //{"abbr":"AK", "name":"Alaska"},
        //{"abbr":"AZ", "name":"Arizona"}
        //...
    ]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    value:'Select...',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});

答案 1 :(得分:7)

您实际上应该使用此{/ p>的emptyText配置属性

{
   ...
   emptyText : 'Select ...',
   ...
}