View Full Version : Store re-usable custom queries?

22 Sep 2013, 2:39 AM
Hi Everyone,

Its been a while since I have used ExtJS, so I am just getting used to the architechure of ExtJS 4, But I'm having some difficulty in planning my application structure for the data. Lets say that I am building an e-commerce site for example, which will contain your usual entities such as products, orders, customers etc.

Now when creating the orders store previously in ExtJs 3.4 I would normally create some custom functions in the store object for custom queries, such as:

// Orders Store



Each of these functions would modify the params sent to the backend server or even modify the url in order to get the correct results, but basically using one store and a custom set of re-usable queries throughout the application rather than setting parameters/urls throughtout the app. Which can be a bit of a nightmare when something changes and you have to hunt down everywhere the store is created/used.

My question is...

Whats the best way of going about this in ExtJS 4, Alot of the examples provided seem to suggest creating multiple stores such as a OpenOrdersStore, OrdersAwaitingDispatchStore, This seems a bit repetitive to me

Anyone have any thoughts on this?

Thanks for your time

23 Sep 2013, 12:50 AM
Usually I set remoteFilter:true and add support in server for filter query option that is capable to filter anyhow on any property.
Then you can define methods, that will be applied some particular filter set.
However, please note, that in Ext4 store is not just an records fetcher - it is a collection, backing dataviews/grids and you usually you will want every dataviews/grids have its own store instance.

23 Sep 2013, 1:25 AM
Hi ettavolt,

Thanks for your reply, Yeah that's what I used to do with Ext 3 but wasn't sure if the new architecture supported it and wondered if there were more elegant ways of dealing with it,

I'll wait a bit and see if anyone else uses any other methods of doing this, then mark the most suitable as the answer, but it's looking like this is it

Thanks again