What is the best way to remove multiple records with a condition in extjs?
For example:
var store = Ext.create('Ext.data.Store', {
data: [
{name: 'Ed', age: 21},
{name: 'Tommy', age: 15},
{name: 'Aaron', age: 18},
{name: 'John', age: 22}
]
});
I want to remove records which are 'age' is less than 20(In this case, 'Tommy' and 'Aaron'). This question could be same as how to find multiple records which much a condition.
Using just the public API and keeping in mind that you probably won't want to filter the store directly or remove items one-by-one as this will trigger unnecessary redraws on any connected UI components - you could use the following:
var subCollection = store.getData().createFiltered(function(item){
return item.get('age') < 20;
});
store.remove(subCollection.getRange());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With