1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    78
    Vote Rating
    0
    alfa19 is on a distinguished road

      0  

    Default Access the store

    Access the store


    Hello,

    i'm a little bit confused...this is the code:

    Code:
    Ext.onReady(function () {
    
    	Ext.define('Info', {
    		extend: 'Ext.data.Model',
    		fields: [
    			{ name: 'first', type: 'string' },
    			{ name: 'last', type: 'string' },
    			{ name: 'codu', type: 'number' }
    		]
    	});
    
    
    	// create the Data Store
    	var store = Ext.create('Ext.data.Store', {
    		model: 'Info',
    		proxy: {
    			type: 'ajax',
    			url : 'info.php',
    			reader: {
    				type: 'json',
    				root: 'info',
    				successProperty: 'success'
    			}
    		},
    		autoLoad: true
    	});
    	
    	var fst = store.getCount();
    	document.write(fst);
    
    });
    this print 0. But there is a record, in fact if i use this store into a grid one row is displayed with correct data.

    So, why it return 0?

    I wanna use the store var for access the data; example:

    var myVar = store.first();
    var myVar2 = myVar.get('first');

    but it doesn't work.

    Thanks for help

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    4
    Vote Rating
    0
    Bloqs is on a distinguished road

      0  

    Default


    You can use this
    Code:
    record = store.getAt(index);id = record.get('id');
    Where index is the index of the store record you want to access

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    78
    Vote Rating
    0
    alfa19 is on a distinguished road

      0  

    Default


    mmm...i don't think will work.

    i repeat that getCount retrieve a 0 value.

    i've tried:

    record = store.getAt(0);

    but it return undefined. So what should i put into the index value?

    thanks for reply

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    55
    Vote Rating
    0
    Gabanjo is on a distinguished road

      0  

    Default


    Loading the store is an asynchronous event and your code won't wait until it has completed, so your store.getCount() will be executing before the store had loaded.

    To see it in action, add a listener to your store:

    Code:
       listeners : {
              load : function(store) {
                 console.log("store count:" + store.getCount());
                }
       }
    If you put a console.log statement after your document.write you should see the order in which things happen.

    Hope this helps.

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    78
    Vote Rating
    0
    alfa19 is on a distinguished road

      0  

    Default


    sorry but i'm newbie with this framework...i don't understand exactly where i have to put my listener. can u post a complete code based on my first post code?

    thanks a lot

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    78
    Vote Rating
    0
    alfa19 is on a distinguished road

      0  

    Default


    ok, forget it..solved and thank you very much

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi