PDA

View Full Version : combo store filter does not work on first time trying



akel
9 Jul 2008, 2:39 AM
hello all.

i have encountered a weird scenario regarding store.filter. on my linked combo boxes.
at first the filtering to my second comboxes does not work but after trying again it will work every on the 2nd time of try.

here is my code for my parent combo box





new Ext.form.ComboBox({ hiddenName:'cboaction', fieldLabel:jAuditTrailMessages.info.cboLblAction, store: storeActionType,
valueField:'value', displayField:'desc', value:'', typeAhead: false,
triggerAction: 'all',
emptyText:jAuditTrailMessages.info.txtSelectEvent,
editable:false, name:'event', anchor: '95%',
triggerAction: 'all', mode:'local'
, listeners:{select:{fn:function(combo, record, index) {
var comboCls = Ext.getCmp('classificationCmb');
comboCls.setValue('');
comboCls.store.filter('classification', combo.getValue(), true );


});

}}
}
})


please do help been searching for the solution :((

big thanks

akel

wallaboy
21 Jul 2008, 7:25 AM
Hi,
have you solved your problem?
My code is a bit different, but the problem is the same. I used the linked combo tutorial, the one with the local data of USA and MEXICO, and what I have done it's to use JsonStore instead of simpleStore.
I can't solve it with the help of the hints of Saki, because the lastquery:'' , it seems, stops the loading of the values in the second combo.

Here there are the data:


var storeProfiles = new Ext.data.JsonStore({
url:'/admin/Admin/UserGetProfiles' (http://extjs.com/forum/'/admin/Admin/UserGetProfiles'),
fields: ['Id_Profile','Id_Categories','Label','Description']
});
var storePermissions = new Ext.data.JsonStore({
url:'/admin/Admin/UserGetPermissions' (http://extjs.com/forum/'/admin/Admin/UserGetPermissions'),
fields: ['Id_ProfilePermission','Id_Profiles','Id_Permission','Label']
});


Here there are the combo:


comboProfiles = new Ext.form.ComboBox({
id: 'comboprofiles',
store: storeProfiles,
lazyInit:'false',
method: 'POST',
hiddenId: 'Label',
editable:false,
disabled:true,
fieldLabel:'Profile',
valueField: 'Id_Profile',
displayField:'Label',
typeAhead: true,
triggerAction: 'all',
emptyText:'Select a profile...',
selectOnFocus:true,
allowBlank:false,
blankText:'This is a mandatory field',
listeners:{select:{fn:function(combo, value) {
var comboLinkedPermissions = Ext.getCmp('combopermissions');
comboLinkedPermissions.enable();
comboLinkedPermissions.clearValue();
comboLinkedPermissions.store.filter('Id_Profiles', this.getValue());
}}
}

});
comboPermissions = new Ext.form.ComboBox({
id: 'combopermissions',
store: storePermissions,
lazyInit:'false',
method: 'POST',
hiddenId: 'Label',
editable:false,
disabled:true,
fieldLabel:'Permission',
valueField: 'Id_ProfilePermission',
displayField:'Label',
typeAhead: false,
mode: 'remote',
triggerAction: 'all',
emptyText:'Select the permissions...',
selectOnFocus:true,
allowBlank:false,
blankText:'This is a mandatory field'
});


Thanks in advance to everyone who could help us!

wiulma
3 Oct 2008, 8:04 AM
Hi!
I have the same problem.
I have tried to call a initList before to call the filter method.
But nothing change.
Any suggestion?

aconte80
14 Oct 2008, 1:29 AM
i have the same problem trying linking 3 combo boxes.
First run doesn't filter correctly, second ok.
I simply add this line lastquery:'' befor each listener command.

ex:
[...]
mode: 'local',
lastQuery: '',
listeners: {select:{fn:function(combo, value) {
var comboCls = Ext.getCmp('comboV');
[...]

Bye
Andrea

wiulma
14 Oct 2008, 1:32 AM
thanks!
I have resolve my mistake with a config parameter, but now I try with your solution!

ecournane
6 Nov 2008, 11:59 AM
wiulma (http://extjs.com/forum/member.php?u=36815), could you share what you did since I am having this problem and aconte80 (http://extjs.com/forum/member.php?u=19850) solution is not working for me?

wiulma
14 Nov 2008, 12:29 AM
I use 3 config options to determine if add the blank options and the value/text properties of the blank options:


...
arrConfig ['blankOption'] = fgBlank;
if (fgBlank) {
arrConfig ['blankKey'] = blankValue;
arrConfig ['blankText'] = blankText;
}
objCombo = new Ext.form.MyComboBox(arrConfig);

arrConfig is an array that contains all the config of my combo.
And this is the override of the initList method I have write for my combo


initList : function(){
if(!this.list){
var cls = 'x-combo-list';
this.list = new Ext.Layer({
shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
});
var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
this.list.setWidth(lw);
this.list.swallowEvent('mousewheel');
this.assetHeight = 0;
if(this.title){
this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
this.assetHeight += this.header.getHeight();
}
this.innerList = this.list.createChild({cls:cls+'-inner'});
this.innerList.on('mouseover', this.onViewOver, this);
this.innerList.on('mousemove', this.onViewMove, this);
this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
if(this.pageSize){
this.footer = this.list.createChild({cls:cls+'-ft'});
this.pageTb = new Ext.PagingToolbar({
store:this.store,
pageSize: this.pageSize,
renderTo:this.footer
});
this.assetHeight += this.footer.getHeight();
}
if(!this.tpl){
this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
}
this.view = new Ext.DataView({
applyTo: this.innerList,
tpl: this.tpl,
singleSelect: true,
selectedClass: this.selectedClass,
itemSelector: this.itemSelector || '.' + cls + '-item'
});
if (this.initialConfig.blankOption) {
var blankKey = this.initialConfig.blankKey;
if (blankKey==null) {
blankKey = '';
}
var blankText = this.initialConfig.blankText;
if (blankText==null) {
blankText = '&nbsp;nbsp;';
}
var rowRecord = Ext.data.Record.create(this.store.fields);
var arrFields = new Array();
for (i=0,len=this.store.fields.items.length;i<len;i++) {
if (this.store.fields.items[i].name==this.store.reader.meta.id) {
var pValue = " ";
arrFields [this.store.fields.items[i].name] = blankKey;
} else {
arrFields [this.store.fields.items[i].name] = blankText;
}
}
this.store.insert(0, new rowRecord(arrFields));
}
this.view.on('click', this.onViewClick, this);
this.bindStore(this.store, true);
if(this.resizable){
this.resizer = new Ext.Resizable(this.list, {
pinned:true, handles:'se'
});
this.resizer.on('resize', function(r, w, h){
this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
this.listWidth = w;
this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
this.restrictHeight();
}, this);
this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
}
}
}

Stan62970
29 Jul 2009, 5:02 AM
try with expand event

listeners:{
expand:function(){
console.log("toto");
}
}

milestonebass
20 Jan 2010, 10:12 PM
Thank you! Solved the same problem which I was having.