PDA

View Full Version : Remote combo validation problem on filtering



10 Sep 2010, 8:24 PM
HI, i am using extjs 3.2.1 lib and iam new to extjs,
I have implemented combobox with remote with filtering option in the form, i have added forceSelection(true) property to combo for validate the text with store collection and allowblank(false) to combo for enable form save button .
My problem:
Combobox forceSelection property validates the control on the blur event only and clear the combo text , If the user enter the invalid text in the combo the save button is enabled(since i am only checked the allowblank(false) for combo) in the form, and when he hit the save button its gets submitted with invalid text in the combo. I have checked the isvalid() method of form and combo also, inside the save event it also returning the 'true'.


How can i validate in this particular scenario ?

vishalnnsingh
10 Sep 2010, 8:52 PM
please post ur code, I checked ur problem bt can't see this jind of problem. when you save your form whil still in the input mode in any of the combobox wth forsel true and albl false it sends null in the backend. please post ur code.

Condor
10 Sep 2010, 11:19 PM
Haven't tested, but you could try to focus() the btnEl when the button is clicked (that way the combobox is correctly blurred).

12 Sep 2010, 11:32 PM
//its my store..
var majorOperStore = new Ext.data.JsonStore({
root:'res',
storeId:'MOStore',
fields:['typeValue'],
totalProperty: 'totalCount',
baseParams:{ver:verid,query:'',start:0, limit:10},
autoLoad:false,
listeners:{
load: function(a,b,c){
}
},
url:'airCode.htm'
});


//Its my combo..
{
name: 'majorOperator',
ref: 'majorOperator',
xtype: 'combo',
typeAhead: true,
id:'majorOperator',
triggerAction: 'all',
lazyRender:true,
mode: 'remote',
forceSelection : true,
autoCreate: { tag: 'input', type: 'text', maxlength: '4' },
store: majorOperStore,
valueField: 'typeValue',
displayField: 'typeValue',
labelStyle: 'width:130px',
width: 150,
fieldLabel: 'Major Operator',
blankText: 'Major Operator is required',
allowBlank: false,
enableKeyEvents:true,
disableKeyFilter: true,
pageSize:10,
resizable:true,
minListWidth:250,
tpl:'<tpl for="."><div class="x-combo-list-item">{typeValue}</div></tpl>',
minChars:2,
listeners:{
select:function(combo, record, index) {
this.setRawValue(record.get('typeValue'));
}
,blur:function() {
}
,render:function() {
this.el.set(
{qtip:'Type at least ' + this.minChars + ' characters to search in Operator Code'}
);
this.validate();
}
,keydown:{buffer:100, fn:function() {
if(!this.getRawValue()&& this.getRawValue().length>0) {
this.doQuery('', true);
}
}}
}

}