Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: filterBy not working..

  1. #11
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  2. #12
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      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
      0  

    Default 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?

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •