ExtJS:未在字段集内加载的组合数据存储

时间:2011-05-04 20:52:03

标签: extjs combobox datastore

我有一个字段集问题。表单有一个下拉组合,其中包含用户可以选择的日期范围。日期在ArrayStore中。如果我把它放在fieldset之外,那就完美了。但是一旦进入fieldset,它就不会加载数据。我也尝试过使用JSON商店,结果相同。

以下是代码:

{
    name:           'DateFieldSet',
    fieldLabel:     '',
    labelSeparator: ':',
    title:          'Choose a date range',
    collapsible:    false,
    autoHeight:     true,
    allowBlank:     true,
    items:          [
                        {
                            fieldLabel:         'Days in past',
                            hiddenName:         'DateRangeCombo',
                            store:              new Ext.data.ArrayStore({
                                                    id:         0,
                                                    fields:     [
                                                                    'rangeValue',
                                                                    'rangeDescription'
                                                    ],
                                                    data:       [
                                                                    [30, '30 days (04/04/2011 - 05/04/2011)'],
                                                                    [60, '60 days (03/05/2011 - 05/04/2011)'],
                                                                    [90, '90 days (02/03/2011 - 05/04/2011)'],
                                                                    [120, '120 days (01/04/2011 - 05/04/2011)'],
                                                                    [180, '180 days (11/05/2010 - 05/04/2011)'],
                                                                    [270, '270 days (08/07/2010 - 05/04/2011)'],
                                                                    [365, '1 year (05/04/2010 - 05/04/2011)']
                                                    ]
                            }),
                            displayField:       'rangeDescription',
                            valueField:         'rangeValue',
                            editable:           true,
                            triggerAction:      'all',
                            width:              150,
                            listeners:          {select:function() {var numberOfDays = ReportForm.form.findField('DateRangeCombo').getValue();var newDate = DateAdd('05/04/2011', 'D', (numberOfDays * -1)); ReportForm.form.findField('StartDate').setValue(newDate);}},
                            xtype:              'combo'
                        },
                        {
                            fieldLabel:         'Or specify your own:',
                            labelStyle:         'width: 100%; font-weight: bold; text-align: left; color: #15428b; font-size: 11px;',
                            labelSeparator:     '',
                            xtype:              'label'
                        },
                        {
                            fieldLabel:         'Start Date',
                            name:               'StartDate',
                            allowBlank:         true,
                            vtype:              '',
                            checked:            false,
                            value:              '04/04/2011',
                            xtype:              'datefield'
                        }, 
                        {
                            fieldLabel:         'End Date',
                            name:               'EndDate',
                            allowBlank:         true,
                            vtype:              '',
                            checked:            false,
                            value:              '05/04/2011',
                            xtype:              'datefield'
                        }
                    ],
    xtype:          'fieldset'
}

对我而言,这看起来很正常。

编辑〜这是错误:

  

this.proxy未定义

不是很有帮助。

1 个答案:

答案 0 :(得分:1)

你错过mode配置..

{
    xtype: 'combo',
    store: new Ext.data.ArrayStore({
        fields: ['rangeValue', 'rangeDescription'],
        data: [
            [30, '30 days (04/04/2011 - 05/04/2011)'],
            [60, '60 days (03/05/2011 - 05/04/2011)'],
            [90, '90 days (02/03/2011 - 05/04/2011)'],
            [120, '120 days (01/04/2011 - 05/04/2011)'],
            [180, '180 days (11/05/2010 - 05/04/2011)'],
            [270, '270 days (08/07/2010 - 05/04/2011)'],
            [365, '1 year (05/04/2010 - 05/04/2011)']
        ]

    }),
    fieldLabel: 'Days in past',
    displayField: 'rangeDescription',
    valueField: 'rangeValue',

    typeAhead: true,
    mode: 'local',    // add this

    triggerAction: 'all',
    emptyText: 'Select date...',
    listeners: {
        select: function () {
            var numberOfDays = ReportForm.form.findField('DateRangeCombo').getValue();
            var newDate = DateAdd('05/04/2011', 'D', (numberOfDays * -1));
            ReportForm.form.findField('StartDate').setValue(newDate);
        }
    }
}