View Full Version : problem with combo box!
pradeep_123
23 Mar 2007, 4:56 AM
Hi all,
I tried including two combo boxes in a page but it shows error,. Iam using different js files for the text boxes.
Any hint?
Thanks in advance
You should provide us with the HTML and JS source if you need help on this.
pradeep_123
23 Mar 2007, 10:49 PM
html content:
from:
<input name="from" type="text" id="from" size="20"/>
</p>
to:
<input name="to" type="text" id="to" size="20"/>
js array:
Ext.namespace('Ext.exampledata');
Ext.exampledata.cities = [
[ 'Bangalore'],
['Chennai'],
[ 'Cochin'],
[ 'Calicut'],
[ 'Guntur'],
[ 'Hyderabad'],
[ 'Mangalore'],
[ 'Mysore'],
];
Ext.exampledata.cities2 = [
[ '1'],
['2'],
[ '3'],
[ '4t'],
[ '4'],
[ '5'],
[ '6'],
[ '7'],
];
js code:
Ext.onReady(function(){
// simple array store
var store = new Ext.data.SimpleStore({
fields: ['city'],
data : Ext.exampledata.cities // from cities.js
});
var store2 = new Ext.data.SimpleStore({
fields: ['state'],
data : Ext.exampledata.cities2 // from cities.js
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'city',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a city...',
selectOnFocus:true
});
var combo2 = new Ext.form.ComboBox({
store: store2,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a city...',
selectOnFocus:true
});
combo.applyTo('from');
combo2.applyTo('to');
var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'city',
width:135,
forceSelection:true
});
var converted2 = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'state',
width:135,
forceSelection:true
});
});
I tried using seperate js files for the text boxes too. but doesnt work
Animal
23 Mar 2007, 11:16 PM
What error are you getting?
One problem is that you have too many commas. You have a comma after the last Array element in both your data Arrays.
But also, I think you are not using the store correctly.
The "fields" property is an array of fields definitions, not strings.
fields: [{name:"city"}]
pradeep_123
24 Mar 2007, 5:48 AM
Hi animal,
I solved that comma problem. Ithink that doesn't make any problem, the thing is only
one of my combo boxes is active ,
I am getting an error,
s has no properties
ComboBox(Object typeAhead=true triggerAction=all transform=city)ext-all.js (line 184)
(no name)()combo1_cities.js (line 30)
Observable()ext-all.js (line 14)
EventManager()ext-all.js (line 16)
[Break on this error] Ext.form.ComboBox=function(_1){Ext.form.ComboBox.superclass.constructor.call(thi...
Can u please explain how 'field' should be used?
tryanDLS
24 Mar 2007, 9:02 AM
SimpleStore will accept simple arrays to define the fields, so you can do
var store = new Ext.data.SimpleStore({
fields: ['city'],
data: [['Bangalore'],['Chennai'],['Cochin'],['Calicut'],['Guntur'],['Hyderabad'],['Mangalore']]
});
However, the error looks like it's happening on your 'converted' combo. Do you have existing SELECT elements with IDs 'city' and 'state'? Transform is used to take an existing SELECT element, and make it look like an Ext combo.
Animal
24 Mar 2007, 9:40 AM
Use ext-all-debug.js, and in Firebug set "Break on All Errors" in the Script tab.
Then you can see exactly where the error is, and follow the stack trace back to the erroneous code.
pradeep_123
24 Mar 2007, 10:30 PM
Thanks Tim,
U pointed me to the exact error,
Actually I wrongly coded an additional combo ie converted
Now it's workin fine
Thanks again
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.