Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ExtJS 4:存储数据未在存储加载回调函数中填充数据_Extjs_Callback_Extjs4_Load_Store - Fatal编程技术网

ExtJS 4:存储数据未在存储加载回调函数中填充数据

ExtJS 4:存储数据未在存储加载回调函数中填充数据,extjs,callback,extjs4,load,store,Extjs,Callback,Extjs4,Load,Store,为什么records.length设置为大于0的数字,而store.data.length等于0?我基本上是尝试在回调中引用我的存储,这样在我将数据添加到表单之前,我的网格就有了数据。但由于某些原因,存储数据不存在。如果你有更好的方法来达到同样的最终结果,我愿意把它改为你的建议。本质上,每个网格都是基于此代码的包装循环中的不同过滤器动态构建的 var p = item.get('p');

为什么records.length设置为大于0的数字,而store.data.length等于0?我基本上是尝试在回调中引用我的存储,这样在我将数据添加到表单之前,我的网格就有了数据。但由于某些原因,存储数据不存在。如果你有更好的方法来达到同样的最终结果,我愿意把它改为你的建议。本质上,每个网格都是基于此代码的包装循环中的不同过滤器动态构建的

                            var p = item.get('p');
                            var store = Ext.create('App.store.example.MyStore');
                            store.clearFilter(true);
                            store.filter('s', s);
                            store.filter('p', p);

                            store.load({

                                callback: function(records, operation, success) {
alert(store.data.length);
alert(records.length);
                                    var grid = Ext.create('App.view.example.MyGrid', {
                                        store: store
                                    });

                                    formPanel.add(
                                        Ext.create('Ext.form.FieldSet', {
                                            id: p + '_TOP',
                                            title: p,
                                            width: '100%',
                                            anchor: '100%',
                                            layout: {
                                                type: 'vbox',
                                                align: 'stretch'
                                            },
                                            items: [myGrid]
                                        })
                                    );
                                    formPanel.doLayout();


                                }
                            });

                            formPanel.doLayout();
                        });

我想如果我将“remoteFilters”设置为true,它就会工作

但我简化了一点。我在商店创建配置中设置了过滤器。我必须在我的模型中设置两个配置才能使其正常工作。这样,我就不必手动设置过滤器,也不必执行加载(因为我让商店自动加载了它)

查看代码:

                        var store = Ext.create('App.store.example.MyStore', {
                            filters: [{
                                property: 's',
                                value: s
                            },{
                                property: 'p',
                                value: p
                            }]
                        });

                        var grid = Ext.create('App.view.example.MyGrid', {
                            store: store
                        });
                        formPanel.add(
                            Ext.create('Ext.form.FieldSet', {
                                id: p + '_TOP',
                                title: p,
                                width: '100%',
                                anchor: '100%',
                                layout: {
                                    type: 'vbox',
                                    align: 'stretch'
                                },
                                items: [grid]
                            })
                        );
autoLoad: true,
remoteFilter: true,
存储配置:

                        var store = Ext.create('App.store.example.MyStore', {
                            filters: [{
                                property: 's',
                                value: s
                            },{
                                property: 'p',
                                value: p
                            }]
                        });

                        var grid = Ext.create('App.view.example.MyGrid', {
                            store: store
                        });
                        formPanel.add(
                            Ext.create('Ext.form.FieldSet', {
                                id: p + '_TOP',
                                title: p,
                                width: '100%',
                                anchor: '100%',
                                layout: {
                                    type: 'vbox',
                                    align: 'stretch'
                                },
                                items: [grid]
                            })
                        );
autoLoad: true,
remoteFilter: true,