PDA

View Full Version : ComboBox select error



hadi.elmougi
24 Feb 2010, 2:57 AM
I have a ComboBox inside fieldset inside window, when I try to select index in the combo i get the following error
this.view is undefined
this.view.select(index);

and here is my code for selecting the index inside the combobox


var typecombo = new Ext.form.ComboBox({
id : 'SupplierType',
fieldLabel : 'Type',
xtype : 'combo',
store : Ext.vedata.typesstore,
displayField : 'des',
valueField : 'recordId',
hiddenName : 'type',
typeAhead : true,
mode : 'local',
forceSelection : true,
triggerAction : 'all',
emptyText : 'Select type...',
selectOnFocus : true,
name : 'type',
width : 100,
bodyBorder : false,
border : false,
style : 'text-align:left;'
});


var updateSupplierFieldSet = {
xtype : 'fieldset',
..........
,
items : [ {
.............. // other items here
,
typecombo

]
};

win = new Ext.Window(
{
layout : 'fit',
width : 500,
height : 250,
closeAction : 'hide',
plain : true,
closable : false,
modal : true,
floating : true,
title : 'Supplier',
shadow : true,
items : updateSupplierFieldSet,
});


win.show();
typecombo.select(Ext.vedata.typesstore.find('des',Ext.model.curr.data.type,0,true,false),true);


need help on this plz

fay
24 Feb 2010, 4:48 AM
A couple of things:

1. Post in CODE tags.

2. I think the hiddenName and name config options of your combo should be different. See docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox):


if the ComboBox name and hiddenName are the same, you should specify a unique hiddenId.

3. You have an extra comma here that will cause problems in IE:


items : updateSupplierFieldSet,
});

4. Are you certain that you store is loaded before calling select(). From the docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox):


The store must be loaded and the list expanded for this function to work, otherwise use setValue.

5. Split out:


typecombo.select(Ext.vedata.typesstore.find('des',Ext.model.curr.data.type,0,true,false),true);
to:


var recordIndex = Ext.vedata.typesstore.find('des',Ext.model.curr.data.type,0,true,false);
if (recordIndex != -1) {
typecombo.select(recordIndex, true);
}

and check that recordIndex is valid.