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