View Full Version : Two components using same store, but filtered differently?

19 Nov 2013, 11:12 AM
Is it possible to use the same store instance with two separate components, but have each of the components filter that store differently (without affecting each other)?

19 Nov 2013, 11:54 AM
I think you have to implement your filtering in this case in the view layer. On what kinds of components you want to use your store with? You could iterate nodes on a view and make them visible or hidden.

19 Nov 2013, 12:04 PM
Basically I have a dataview, a menu, and a toolbar, which initially contain all the same items, but may be customized by the user individually at a later point. So my hopes were that I could leave the store intact with all the data, but then filter it down per component without affecting each of the components as I change the store. I would end up using a few flag fields of the store to determine the different components the items are mapped to.

At some point I want to facilitate dragging and dropping the items between components, and updating the store to set the flags for where the items should show up.

19 Nov 2013, 12:12 PM
In that case keep the store intact, just iterate the items. DataView nodes are retrievable, you can make them hidden. As well menuitems or toolbar items.

20 Nov 2013, 12:51 AM
thanks for the information shown here, they are really the useful one for us to be shown everytime herre

Tevida (http://www.healthisgod.com/tevida-testosterone-booster/)

20 Nov 2013, 8:43 AM
Would it not be possible to have a store with everything in it and then create derived stores from that with the differing sorting configurations in them? Basically coming from an object orientated approach.

20 Nov 2013, 8:55 AM
I was thinking about that, but I wasn't sure if there was a way to clone a store (or how to load one store from another), and or how that would work in terms up making updates back to the database. Would updating a child store update the parent store, that would then update the database?

21 Nov 2013, 11:56 AM
Simple example that uses two comboboxes that are setup to derive their stores from single store.

Ext.define('State', { extend: 'Ext.data.Model',
fields: [
{type: 'string', name: 'abbr'},
{type: 'string', name: 'name'},
{type: 'string', name: 'slogan'}

// The data for all states
var states = [
{"abbr":"AL","name":"Alabama","slogan":"The Heart of Dixie"},
{"abbr":"NM","name":"New Mexico","slogan":"Land of Enchantment"},
{"abbr":"OH","name":"Ohio","slogan":"The Heart of it All"},
{"abbr":"OK","name":"Oklahoma","slogan":"Oklahoma is OK"},
{"abbr":"WA","name":"Washington","slogan":"Green Tree State"},
{"abbr":"WV","name":"West Virginia","slogan":"Mountain State"},
{"abbr":"WI","name":"Wisconsin","slogan":"America's Dairyland"},
{"abbr":"WY","name":"Wyoming","slogan":"Like No Place on Earth"}

Ext.define('StatesStore', {
extend: 'Ext.data.Store',
storeId: 'StatesStore',
alias: 'store.states',
model: 'State',
data: states

Ext.onReady(function() {

var simpleCombo1 = Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Filter',
renderTo: 'simpleCombo1',
displayField: 'name',
width: 320,
labelWidth: 130,
store: {type: 'states'},
queryMode: 'local',
typeAhead: true
var simpleCombo2 = Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'UnFiltered',
renderTo: 'simpleCombo2',
displayField: 'name',
width: 320,
labelWidth: 130,
store: {type:'states'},
queryMode: 'local',
typeAhead: true

var button = Ext.create('Ext.button.Button', {
text: 'Filter Store',
renderTo: 'buttonFilter',
handler: function () {
simpleCombo1.getStore().filter('name', "Ohio");
simpleCombo2.getStore().filter('name', "Wyoming");
var clear = Ext.create('Ext.button.Button', {
text: 'Clear',
renderTo: 'clearFilter',
handler: function () {