I have a remote store using a MySQL database.
here is the store definition
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'
}
}
});
I have an array of ids, those i want to keep so i need to apply a filter. I found 2 different solutions but none worked. The first was using filtreBy method
Ext.getStore('sOutil').filterBy(function(record, id) {
return Ext.Array.contains(ids_intervenant_outils, record.get('id'));
});
I did this bug i get an error in Firefox "too much recursion". So i tried an other way to do it and found this on an other stack-overflow post (here) but I ge Ext.escapeRe
which according to firefox "is not a function". I tried to find an other function i found Ext.String.escapeRegex()
but I got one more error in Firefox "p.replace is not a function"
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);
here is the too much recursion calls trace
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 ...