myMixedCollection
将是记录(模型实例)的集合,只要新商店具有相同的模型集,这将起作用!所以答案是肯定的
好吧,您肯定需要在实例上调用getRange()myMixedCollection
这是一个工作示例
// Set up a model to use in our Store
Ext.define('Simpson', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'email', type: 'string'},
{name: 'phone', type: 'string'}
]
});
var s1 = Ext.create('Ext.data.Store', {
model:'Simpson',
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
var mixed = s1.queryBy(function(rec){
if(rec.data.name == 'Lisa')
return true;
});
var s1 = Ext.create('Ext.data.Store', {
model:'Simpson',
storeId:'simpsonsStore2',
fields:['name', 'email', 'phone'],
data: mixed.getRange(),
proxy: {
type: 'memory',
reader: {
type: 'json'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore2'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
和JSFiddle