PDA

View Full Version : Load store with params



donovanb
4 Jun 2015, 12:20 AM
Hello everyone,


I'm trying to load store with params in order to filter my data (as "where" in SQL) however I didn't find how to do that ...
Therefore, I made a filter on store load in order to make this but when there are many data, lags appears because it load all data and then filter them.

Is it possible to load store with params ? I tried for example :

store.load({
params: { id : '300'},
});
But it's not working ..

Here is my code;
(I'm using ExtJS3.4 in a GroupOffice module (MVC model) that's why you can see "GO.", ... ).

I declare my store

GO.gestionfrais.storeAffichageMesFrais = new GO.data.JsonStore({
url: GO.url('gestionfrais/frais/store'), // URL to my model
fields: ['id',...],
// method: 'POST', // Have I to write this line ?
// read: 'POST',
model: 'GO\\Gestionfrais\\Model\\Frais',
});


Then I created my filter:


GO.gestionfrais.storeAffichageMesFrais.on('load', function(){
GO.gestionfrais.storeAffichageMesFrais.filterBy( function(record, id) {
if(record.get("id_user") == id_currentUser && record.get('archive') == 'Non' ) {
return true;
}
return false;
}, this);
});


And finally I load my store

GO.gestionfrais.storeAffichageMesFrais.load( /*{params ?}*/ );


Thanks for reading me.