[英]How to get the associated store in Sencha Touch?
嗨,我正在使用Sencha Touch应用程序,并且在一个名为“客户”的商店中有一个模型关联,我知道当您创建模型关联时,会自动在后台创建一个新商店,我的问题是:如何获得此模型存储称为“ templatesStore”(我在Chrome控制台中看到了结果)以供以后过滤?
先感谢您。
可以使用以下语法来完成:
<mainStore>.getAt(0).<assosiationName>();
例如,如果主商店是“客户”,并且名称关联指定为“模板”,则:客户模型中指定关联:
hasMany: [
{
model: 'sample.model.Template',
associationKey: 'templates',
name: 'templates' // name given here will be accessed from main store
},
]
获取模板存储:
Ext.getStore('Customer').getAt(0).templatesStore;
要么
Ext.getStore('Customer').getAt(0).templates();
要根据模板值过滤“客户”商店,请执行以下操作:
Ext.getStore('Customer').filter([
{ filterFn: function (item) {
item.templatesStore.filter('templateValue',templateValue); // templateValue contains the value of selected template
if(item.templatesStore.getCount()>0)
return true;
else
return false;
}
}
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.