PDA

View Full Version : exampledata not found.



blah32
17 Apr 2007, 9:59 AM
Tried states.js first. Could Find. Include in Function, still nothing am I missing something?
<div id="local-states" size="20">
<script>
Ext.exampledata.states = [
['AL', 'Alabama'],
['AK', 'Alaska'],
['AZ', 'Arizona'],
];

var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : exampledata
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true
});
combo.applyTo('local-states');
</script>
</div>

MrKurt
17 Apr 2007, 10:17 AM
Try this:

<div id="local-states" size="20"></div>
<script>
var exampledata = [
{abbr:'AL', state:'Alabama'},
{abbr:'AK', state:'Alaska'},
{abbr:'AZ', state:'Arizona'}
];

var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : exampledata
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true
});
combo.applyTo('local-states');
</script>


Here's what I changed:

Made an actual "exampledata" variable, which was missing before
Put objects in it, rather than arrays. I'm pretty sure the combo box needs named fields, the way you're using it
Closed the <div> before the script started.

tryanDLS
17 Apr 2007, 10:19 AM
Extra comma after Arizona?

blah32
17 Apr 2007, 10:42 AM
this.el.dom.value.length is null or object.

tryanDLS
17 Apr 2007, 10:48 AM
I don't what your code is now, but your original post declared 'Ext.exampledata.states', but used 'exampledata' in the store.

blah32
17 Apr 2007, 10:52 AM
<div id="local-states" size="20"></div>
<script>
var exampledata = [
{abbr:'AL', state:'Alabama'},
{abbr:'AK', state:'Alaska'},
{abbr:'AZ', state:'Arizona'}
];

var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : exampledata
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true
});
combo.applyTo('local-states');
</script>

tryanDLS
17 Apr 2007, 11:17 AM
It shouldn't be an array of objects, it should be a nested array, like the original. If it still doesn't work, step thru in Firebug and see what el it's failing on.

MrKurt
17 Apr 2007, 12:58 PM
Whoops, my mistake.