1. #11
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    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


    That object in the console will get updated as long as you haven't expanded. So if you console.log(store) and the store finishes being loaded before you expand the store then you will see the updated store.

    You need to get a number or string or boolean to see if the store has loaded, I usually do

    Code:
    console.log(store.getCount());
    That will not update as the store loads.
    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.

  2. #12
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    I have this and it works for me:

    Store:

    Code:
    var listaMatStore = new Ext.data.Store ({
    	autoLoad: true,
    	model: 'listaMatModel',
    	sorters: 'DescMaterial',
        getGroupString : function(record) {
            // Group by the last name
            return record.get('DescMaterial')[0];
        },
    	proxy:
    	{
    		type: 'rest',
    		url: 'data/materiales.txt',
    		reader:
    		{
    			type: 'json',
    			root : 'root'
    		}
    	}
    });
    List:

    Code:
    var listaMat = new Ext.List({	id: 'listaMat',
    	store: listaMatStore,
            grouped: true,
    	itemTpl:
    	'<div class="materialItem">'+
    		'<div class="item-img"><img src="resources/images/shopping_cart.png" width="50" height="50"></div>'+
    		'<div style="float:left; width:90%;">'+
    		'<div class="list-codigo">'+
    			'<span>{CodMaterial}&nbsp;&nbsp;&nbsp;{CodUMedida}-{UMedidaRendimiendo}</span>'+
    			'<br />'+
    			'{DescMaterial}'+
    		'</div>'+
    		'<div class="list-peso">'+
    			'<span>Peso: {Peso} KG&nbsp;&nbsp;&nbsp;Precio: {PrecioUnit} PEN</span>'+
    			'<br />'+
    			'<span>Stock: {Stock}&nbsp;UN</span>'+
    		'</div>'+
    		'</div>'+
    	'</div>',
    	listeners: {
    		'render': function (thisComponent) {
    			var desc = formBuscaMat.getValues().descripcion;
    			if(desc){
    				thisComponent.getStore().load();
    				thisComponent.getStore().filter('DescMaterial',desc);
    			}
    			else{
    				thisComponent.getStore().load();
    			}
    		}
    	}
    });

  3. #13
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Vote Rating
    0
    MauiRa is on a distinguished road

      0  

    Default Don't you filterBy before loading?

    Don't you filterBy before loading?


    I may be misunderstanding the life cycle of the store but I thought filterBy determines what gets loaded when you call store.load();

    So, If we do this:

    store.filterBy(function(item,id){
    //If we found the correct item
    return true;
    }, this);

    store.load();

    The store should now have the records filtered by the criteria.

    Is this a correct assumption?

    If I am correct, then why should the store already have items in its data before applying the filter?