PDA

View Full Version : store.filter does not filter



phamtranquocviet
30 Sep 2012, 3:49 PM
Hi,

store.filter does not filter. My combo boxes always have both "Catechism" and "Vietnamese". I want the first combo to contain only catechism, and the second one to contain only "Vietnamese". Here is my controller:


Ext.define('Glvn.controller.children.tracking.RegistrationTabs', {
extend: 'Ext.app.Controller',

handleSuccessfulClassesLoad: function(records, operation, success) {
console.log(records);
var catechismCombo, store;

store = Ext.StoreManager.lookup("classes-store");
catechismCombo = Ext.ComponentQuery.query('#catechismClass')[0];
store.filter('type', 'Catechism');
catechismCombo.bindStore(store);
catechismCombo.enable();

vietnameseCombo = Ext.ComponentQuery.query('#vietnameseClass')[0];
store.filter('type', 'Vietnamese');
vietnameseCombo.bindStore(store);
vietnameseCombo.enable();
},

handleSchoolChange: function() {
Ext.create('Glvn.store.children.Classes').load({
params: {
schoolId: Ext.ComponentQuery.query('#school')[0].getValue()
},
callback: this.handleSuccessfulClassesLoad
});
},

init: function() {
this.control({
'window[id=my-children-window] panel[region=center] #school': {
change: this.handleSchoolChange
}
});
}
});


Here is my data to be filtered:


[{"classId":"1","className":"Catechism 1","type":"Catechism"},{"classId":"2","className":"Catechism 2","type":"Catechism"},{"classId":"3","className":"Catechism 3","type":"Catechism"},{"classId":"4","className":"Catechism 4","type":"Catechism"},{"classId":"5","className":"Catechism 5","type":"Catechism"},{"classId":"6","className":"Catechism 6","type":"Catechism"},{"classId":"7","className":"Catechism 7","type":"Catechism"},{"classId":"8","className":"Catechism 8","type":"Catechism"},{"classId":"9","className":"Vietnamese 1","type":"Vietnamese"},{"classId":"10","className":"Vietnamese 2","type":"Vietnamese"},{"classId":"11","className":"Vietnamese 3","type":"Vietnamese"},{"classId":"12","className":"Vietnamese 4","type":"Vietnamese"},{"classId":"13","className":"Vietnamese 5","type":"Vietnamese"},{"classId":"14","className":"Vietnamese 6","type":"Vietnamese"},{"classId":"15","className":"Vietnamese 7","type":"Vietnamese"},{"classId":"16","className":"Vietnamese 8","type":"Vietnamese"}]


What am I doing wrong? Thanks.

phamtranquocviet
30 Sep 2012, 4:47 PM
I figured it out. Here is my new and working controller. Once lesson I learned: don't share store. It makes things complicated and may even be impossible to separate when submitting data.



Ext.define('Glvn.controller.children.tracking.RegistrationTabs', {
extend: 'Ext.app.Controller',

handleSuccessfulVietnameseClassesLoad: function(records, operation, success) {
var vietnameseCombo, store;

store = Ext.StoreManager.lookup("vietnamese-classes-store");
store.filter('type', 'Vietnamese');
vietnameseCombo = Ext.ComponentQuery.query('#vietnameseClass')[0];
vietnameseCombo.bindStore(store);
vietnameseCombo.enable();
},

handleSuccessfulCatechismClassesLoad: function(records, operation, success) {
var catechismCombo, store;

store = Ext.StoreManager.lookup('catechism-classes-store');
store.filter('type', 'Catechism');
catechismCombo = Ext.ComponentQuery.query('#catechismClass')[0];
catechismCombo.bindStore(store);
catechismCombo.enable();
},

handleSchoolChange: function() {
Ext.create('Glvn.store.children.CatechismClasses').load({
params: {
schoolId: Ext.ComponentQuery.query('#school')[0].getValue(),
type: 'Catechism'
},
callback: this.handleSuccessfulCatechismClassesLoad
});
Ext.create('Glvn.store.children.VietnameseClasses').load({
params: {
schoolId: Ext.ComponentQuery.query('#school')[0].getValue(),
type: 'Vietnamese'
},
callback: this.handleSuccessfulVietnameseClassesLoad
});
},

init: function() {
this.control({
'window[id=my-children-window] panel[region=center] #school': {
change: this.handleSchoolChange
}
});
}
});

scottmartin
1 Oct 2012, 5:05 AM
Thank you for the update.

Scott.