1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    23
    Vote Rating
    0
    emm is on a distinguished road

      0  

    Default Filters in sencha touch

    Filters in sencha touch


    Hey guys,
    I am trying to user filters and was wondering if you encountered any issue like I did. Or I must be doing something wrong!
    I have a view with a list linked to a store where I want to display only records where attribute can_communicate_to_current_user is set to false.
    I tried different ways of doing this.

    1/ Applying the filter to the store:
    Code:
    Ext.regStore('Bomb', {
        model: 'User',
    	autoLoad: false,
    	proxy: {
    		type: 'ajax',
    		url: APP_DOMAIN_URL + '/users',
    		actionMethods: {
    			read: 'GET'
    		},
    		extraParams: {
    			within: 50
    		},
    		reader: {
    			type: 'json',
    			totalProperty: 'total',
    			root: 'data'
    		}
    	},
    	filters: [
    	        {
    	            property : 'can_communicate_to_current_user',
    	            value: false
    	        }
    	    ],
    });
    That returns a 500 error from the server as it doesn't like that we added parameters to the request:

    Code:
    _dc:1311216601992
    within:5
    limit:25
    filter:[{"property":"can_communicate_to_current_user","value":"false"}]
    Normaler this filer parameter is not sent.

    I tried with specifying a filter function, like this:
    Code:
    filters: [
    	       function (o,k){
    				return (o.data.relationship_status.accepted == false) ;
    			}
    	    ]
    but I get the same error from server.
    Then I was stuck so I tried to filter in the view

    2/Filter in the list
    Code:
    items: [{
    				xtype: 'list',			
    				store: 'Bomb',
    				filters: [
    				        {
    				            property : 'can_communicate_to_current_user',
    				            value: false
    				        }
    				    ],
                                        ....
    But the list is not filtered at all!
    I tried with a filter function as well but that didn't work neither.
    Then I tried something ugly...

    3/ The only thing that seems to work is by doing this:
    Code:
    			items: [{
    				xtype: 'list',			
    				store: 'Bomb',
    				prepareData: function(data){
    					return (data.can_communicate_to_current_user == false)? data:undefined;
    				},
                                    ....
    But that leaves blank items in the list, which is not really nice to see for the end user...

    Any hint on what I did wrong with filters?
    Thank you guys!
    Emmanuel

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    51
    Vote Rating
    2
    art.dev.ext is on a distinguished road

      0  

    Default


    1/ Try to set
    filterParam:null
    on your Proxy

    If it does not work, check that store.filterOnLoad==true and store.remoteFilter == false

    2/ Anyway and according to the documentation, there is not "filter" property on Ext.List

    You can filter store after loaded event :
    store.filter("prop","value") or store.filterBy(function)

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    23
    Vote Rating
    0
    emm is on a distinguished road

      0  

    Default



    That fixed the issue!
    Thank you Master of Filters

  4. #4
    Sencha User
    Join Date
    Mar 2008
    Posts
    129
    Vote Rating
    0
    art.home.ext is on a distinguished road

      0  

    Default


    Filtering is definitely not my cup of tea...
    I was spending my time in debugging it with sencha-touch-debug when you created this thread.
    I would not have been able to give you the same response today
    I've overshadowed it
    Store configuration properties conflicts drive me crazy...

Thread Participants: 2

Tags for this Thread

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