0

我正在使用 ext4。我必须使用存储中的数据填充四个具有不同值的组合框。但是在 store 上使用 collect 方法时,它会给出空数组。当我在商店中有静态数据时它可以工作,但是当我在商店中使用代理获取数据时它不起作用。

    /* inside view */
    initComponent: function() {
            console.log('inside menu Panel ');
            var me = this;
            var filterCriteriaStore = Ext.create('ITChart.store.StoreForMenu');
            Ext.applyIf(me, {
                defaults:{
                    margin:'20 40 20 20'
                },
                items: [
                        {
                            xtype: 'combo',
                            id: 'territory',
                            store: filterCriteriaStore.collect('territory'),
                            displayField: 'territory',
                            valueField:'territory',
                            maxWidth:'100',
                            margin: '20 40 20 0',
                            value: 'ABC'
                        },
                        {
                            xtype: 'combo',
                            id: 'content',
                            store: filterCriteriaStore.collect('content'),
                            displayField: 'content',
                            valueField:'content',
                            maxWidth:'100',
                            value: 'XYZ'
                        }
                        ]

            });
            me.callParent(arguments);
        }

    /* not working */
    /* inside store */
    proxy: {
            type: 'ajax',
            url : 'http://localhost:8080/ServiceName/getFilterCriteriaExt',
            reader: {
                type: 'json',
                root: 'responseDTO'
            }/*,
            headers: {
                'Content-Type': 'application/json; charset=utf-8; Cache-Control: no-cache'
            }*/
            //actionMethods: 'POST'
        },

    /* working */
    /* inside store */
    data : [
{"content":"XYZ","type":"Song","territory":"ABC","payment":"Paid","errorCode":""},{"content":"Music","type":"Album","territory":"ABC","payment":"Paid","errorCode":""},{"content":"XYZ","type":"Song","territory":"IND","payment":"Paid","errorCode":""},
{"content":"Music","type":"Album","territory":"ABC","payment":"Paid","errorCode":""},
{"content":"Movie","type":"Song","territory":"CHINA","payment":"NotPaid","errorCode":""},
{"content":"Music","type":"Song","territory":"IND","payment":"NotPaid","errorCode":""}
    ]
4

1 回答 1

1

您确定商店此时已加载吗?否则,您必须先加载您的商店,因为当您定义静态数据时,它不必实际加载。

var filterCriteriaStore = Ext.create('ITChart.store.StoreForMenu');
filterCriteriaStore.load();
于 2012-12-07T12:48:43.037 回答