View Full Version : How to get the data from a store

27 Feb 2014, 1:32 AM
If use local data to create a store ,that ok .

but if the store data load from a json file ,
the strore.length still zero,
somebody know why?

this OK:
var store= Ext.create('Ext.data.Store', {
fields: [ 'name',],
data :local_data

this is my test code ,this no data

var aaa = Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'},
{name: 'age', type: 'int'},
{name: 'eyeColor', type: 'string'}

var store = Ext.create('Ext.data.Store', {
autoLoad: true,
model: "User",
proxy: {
type: 'ajax',
url: 'data/users.json',
reader: {
type: 'json',
root: 'users'

the users.json file
"users": [{
"id": 1,
"name": "Ed",
"orders": [{
"id": 10,
"total": 10.76,
"status": "invoiced"
"id": 11,
"total": 13.45,
"status": "shipped"

27 Feb 2014, 2:07 AM
the store is not an array. you can use store.getRange() to get all the records in the store and store.getCount() to get a count of the number of records in the store. Please take a look at the documentation: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store