PDA

View Full Version : [CLOSED] [PR1] Ext.data.Store.filterBy(...) keeps wrong records



SunboX
2 Nov 2011, 3:17 AM
REQUIRED INFORMATION

Ext version tested:

Sencha Touch 2.0PR1

Browser versions tested against:


Safari 5.1 (Windows)

Description:

If I use the filterBy() function of an Ext.data,Store (bound to a List) it filters wrong data sets. (See Demo)

Test Case:


Ext.require([
'Ext.data.Store',
'Ext.List'
]);

Ext.define('TestModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'distance', type: 'string'}
]
});

Ext.setup({
onReady: function() {

var store = Ext.create('Ext.data.Store', {
model: 'TestModel',
data : [
{name: 'Ed', distance: '10 km'},
{name: 'Tommy', distance: '20 km'},
{name: 'Aaron', distance: '20 km'},
{name: 'Jamie', distance: '30 km'},
{name: 'André', distance: '45 km'}
]
});

var list = Ext.create('Ext.List', {
fullscreen: true,
title: 'Demo Time',
itemTpl: '{name} - {distance}',
store: store
});

store.filterBy(function(record){
return record.get('distance') === '20 km';
});
list.refresh();
}
});

HELPFUL INFORMATION

See this URL for live test case:
http://jsfiddle.net/QYJpc/18/

greetings Sunny

SunboX
2 Nov 2011, 3:35 AM
Workaround

Refreshing the List two times, does fix it.


Ext.setup({

//...

onReady: function() {

//...

store.filterBy(function(record){
return record.get('distance') === '20 km';
});

list.refresh();
list.refresh();
}
});

greetings Sunny

Jamie Avins
2 Nov 2011, 7:46 AM
Yes, we are aware of this issue. Thank you for the report.