How to extract the data from data.store to an array?

和自甴很熟 提交于 2019-12-06 11:38:16

getRange() ought to do it. Make sure the "R" is capitalized.

Assuming that's just a typo in your question, if getRange() isn't returning an array of records, it's likely that your store is not loading records properly. Are you sure your store is loading the records properly? Use firebug to inspect the store after load.

EDIT Looks like you're running getRange() before the store is done loading the data. You're loading the store upon creation (autoLoad:true), but then you're immediately running getRange() (while the XMLHttpRequest is still pending in the background!).

You'll need to listen for the store's load event, and have a handler to manipulate the data.

EDIT2 This Works:

Ext.onReady(function(){
        console.log('hi');
        var prstore = new Ext.data.Store({
                url: 'xmlformat.xml',
                autoLoad: true,
                reader: new Ext.data.XmlReader({
                        record: 'price'
                    }, [{name: 'Pri', mapping: '@rate'}])
            });

        prstore.on('load',function(store,records,opts){                    
                console.log(store.getRange());
            });


    });

You should be able to see an array of Ext.data.Record objects in your firebug console.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!