ExtJs 4.2 - 带有表单字段的Property Grid?

时间:2014-06-22 10:57:40

标签: extjs extjs4.2

我尝试创建属性网格,并在值列中包含表单字段。默认情况下,当我单击该值时,它将变为文本输入。但我希望它始终可见为文本字段或组合框或日期选择器等。我尝试使用sourceConfig,但没有运气。怎么做?

这是我的一些代码:

Ext.create('Ext.grid.property.Grid', {
    title: 'Details',
    id: 'settings-details',
    source: {
        "Username": "Username", //Need a text input
        "Email": "Email",
        "State": "State"        //Need a combo
    },
    sourceConfig: {
        "Username": {
            editor: Ext.create('Ext.form.field.Text', { allowBlank: true }),
            displayName: 'Whatever'
        }
    }
}),

1 个答案:

答案 0 :(得分:1)

您需要在sourceConfig中定义组合或使用如下变量:

var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
        // More states here....
    ]
});

Ext.create('Ext.grid.property.Grid', {
   title: 'Details',
   id: 'settings-details',
   width: 300,
   renderTo: Ext.getBody(),
   source: {
       Username: "Username", //Need a text input
       Email: "email@domain.com",
       state: "State"        //Need a combo
   },
   sourceConfig: {
       state: {
           editor: Ext.create('Ext.form.ComboBox', {
              fieldLabel: 'Choose State',
              store: states,
              queryMode: 'local',
              displayField: 'name',
              valueField: 'abbr'
           }),
           displayName: 'State'
        }
    }
});

这应该将组合设置为您的州编辑器......