【发布时间】:2018-05-25 08:47:33
【问题描述】:
我有一个使用 MySQL 数据库的远程存储。
这是商店定义
Ext.define('rgpd.store.sOutil', {
extend: 'Ext.data.Store',
requires: [
'rgpd.model.mOutil'
],
model: 'rgpd.model.mOutil',
autoLoad: true,
autoSync: true,
pageSize: 0,
remoteSort: true,
remoteFilter: true,
proxy: {
type: 'ajax',
api: {
create: 'data/app.php?class=Outil&action=create',
read: 'data/app.php?class=Outil&action=read',
update: 'data/app.php?class=Outil&action=update',
destroy: 'data/app.php?class=Outil&action=destroy',
},
reader: {
type: 'json',
root: 'data',
totalProperty: 'totalCount',
successProperty: 'success'
},
writer: {
type: 'json',
writeAllFields: false,
successProperty: 'success',
encode: true,
extraParams: "id",
idProperty: "id",
rootProperty: 'data'
}
}
});
我有一个 id 数组,我想保留这些,所以我需要应用过滤器。 我找到了 2 种不同的解决方案,但没有一个有效。第一个是使用filtreBy method
Ext.getStore('sOutil').filterBy(function(record, id) {
return Ext.Array.contains(ids_intervenant_outils, record.get('id'));
});
我做了这个错误,我在 Firefox 中得到一个错误“递归过多”。所以我尝试了另一种方法来做到这一点,并在另一个堆栈溢出帖子(here)上找到了这个,但我得到了Ext.escapeRe,根据 Firefox“不是一个函数”。我试图找到我找到的另一个函数 Ext.String.escapeRegex() 但我在 Firefox 中又遇到了一个错误“p.replace 不是函数”
var filterValue = Ext.isArray(ids_intervenant_outils)
? new RegExp('^(?:' + Ext.Array.map(ids_intervenant_outils, function(value){return Ext.String.escapeRegex(value)}).join('|') + ')$')
: values;
Ext.getStore('sOutil').clearFilter(false);
Ext.getStore('sOutil').filter('id', filterValue);
这里有太多的递归调用跟踪
RegExpGlobalReplaceOptFunc self-hosted:4702:22
[Symbol.replace] self-hosted:4499:24
replace self-hosted:5248:13
encodeString http://localhost/rgpd/extjs6/ext-all.js:22:383387
doEncode http://localhost/rgpd/extjs6/ext-all.js:22:382867
encodeObject http://localhost/rgpd/extjs6/ext-all.js:22:384535
doEncode http://localhost/rgpd/extjs6/ext-all.js:22:383117
encodeObject ...
【问题讨论】:
-
在经过编写器时,过多的递归与序列化有关。树中有一些自引用对象。