如何从 ExtJS 存储中打印(或警告)值?

How to print (or alert) value from ExtJS store?

我正在尝试从 ExtJS 存储中获取一个值以在变量中使用它。我尝试按照 Whosebug 和 Sencha 论坛上回答的另一个问题的说明使用 console.log 打印它,但没有成功。我在第一次尝试时收到此错误消息:

Cannot read property 'data' of undefined

这是我第二次尝试时收到的消息:

myView is not defined

其中 "myView" 是当前 window 的 class 名称。

这是我的商店代码:

myStore = this.store = new Ext.data.JsonStore({
                proxy:new Ext.data.ScriptTagProxy({
                    url: "php/data.php"
                }),
            root: 'result',
            autoLoad: false,
            fields: [
                {name:'ID',type:'string',mapping:'ID'},
                {name:'NAME',type:'string',mapping:'NAME'}

            ]
        });

以下是我尝试从商店获取值的方式:

第一次尝试:

var vId = myStore.data.items[0].data.ID;
console.log(vId);

第二次尝试:

store.storeDadosSol.load(function(){
                this.each(function(record){
                var vId = record.get('ID');
                // Do stuff with value
                console.log(vId);
                });
            });​

我正在关注这些答案:

Sencha Forum

Whosebug Question

有什么想法吗?我正在使用 ExtJS 版本 3.2.1

您的 myStore 声明使用

myStore = this.store =

当您尝试访问存储中的值时,您是否在同一范围内? myStore 是全局变量吗?