Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    68
    Vote Rating
    -1
    jairok is an unknown quantity at this point

      0  

    Exclamation Bug with store / ajax proxy ????

    Bug with store / ajax proxy ????


    Hi,

    Maybe found a bug in store.. very annoying...

    I made a store with ajax proxy, json format.

    When I load the store, the callback has 3 items in records arg, but when I look at the store, he's empty.

    Anyone can help ?

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Can you post a code sample of your issue please.

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This usually means that your fields don't match what is being returned or your reader isn't setup properly so code for your store and model and the response returned is what is needed to help you
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Sencha User
    Join Date
    Dec 2010
    Posts
    68
    Vote Rating
    -1
    jairok is an unknown quantity at this point

      0  

    Default


    The store :
    Code:
    Ext.define('app.store.Seasons', {	extend : 'Ext.data.Store',
    	model : 'app.model.Season',
    	requires : [ 'app.model.Season' ],
    
    
    	proxy : {
    		type : 'ajax',
    		url : 'data/seasons.json',
    		reader : {
    			type : 'json',
    			root : 'seasons'
    		}
    	},
    
    
    	autoLoad : true
    });
    The model:
    Code:
    Ext.define('app.model.Season', {
    	extend : 'Ext.data.Model',
    	fields : [ {
    		name : 'id',
    		type : 'int'
    	}, {
    		name : 'value',
    		type : 'int'
    	}, {
    		name : 'text',
    		type : 'string'
    	} ]
    });
    The response:
    Code:
    {
    	"seasons": [
    
    
    		{
    			"id": 1,
    			"value": 1,
    			"text": "09-10"
    		}, {
    			"id": 2,
    			"value": 2,
    			"text": "10-11"
    		}, {
    			"id": 3,
    			"value": 3,
    			"text": "11-12"
    		}
    	]
    }

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This is exactly what I tried and the store had 3 records in it:

    Code:
    Ext.define('app.model.Season', {
    	extend : 'Ext.data.Model',
    	fields : [ {
    		name : 'id',
    		type : 'int'
    	}, {
    		name : 'value',
    		type : 'int'
    	}, {
    		name : 'text',
    		type : 'string'
    	} ]
    });
    
    Ext.define('app.store.Seasons', {
        extend : 'Ext.data.Store',
    	model : 'app.model.Season',
    	requires : [ 'app.model.Season' ],
    
    	proxy : {
    		type : 'ajax',
    		url : 'data/seasons.json',
    		reader : {
    			type : 'json',
    			root : 'seasons'
    		}
    	},
    
    
    	autoLoad : true
    });
    
    Ext.setup({
        onReady: function() {
    
            var store = Ext.create('app.store.Seasons', {
                listeners : {
                    load: function(store) {
                        console.log(store);
                        console.log(store.getCount()); //returns 3
                        console.log(store.data.getCount()); //returns 3
                    }
                }
            });
        }
    });
    data/seasons.json is exactly this:

    Code:
    {
    	"seasons": [
    
    
    		{
    			"id": 1,
    			"value": 1,
    			"text": "09-10"
    		}, {
    			"id": 2,
    			"value": 2,
    			"text": "10-11"
    		}, {
    			"id": 3,
    			"value": 3,
    			"text": "11-12"
    		}
    	]
    }
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I just had a thought... did you try to get the count of the store after you created the store or in the load event?

    Even though it is localstorage and autoLoad is true, there is still time needed for the load to happen so if you did this:

    Code:
    var store = Ext.create('app.store.Seasons', {});
    console.log(store.getCount());
    It will return zero. If you look at my post before this one, I do the getCount in the load event listener.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User
    Join Date
    Dec 2010
    Posts
    68
    Vote Rating
    -1
    jairok is an unknown quantity at this point

      0  

    Default


    Ok, I think I understand my mistake.

    I try
    Code:
    this.getSeasonsStore().getCount()
    without using the Ext.create