PDA

View Full Version : Problem reading values in XTemplate for a Combobox with an static Array as store)



Zerogiven
27 Mar 2010, 7:09 AM
Hi :)

So i tried and searched a lot, but i found no solution for my (maybe simple) problem.
I've a quite simple combobox with an static array as store:


new Ext.form.ComboBox({
store: ["TEST","TEST2"],
typeAhead: true,
forceSelection: true,
tpl: loginComboTpl,
triggerAction: 'all',
value: "TEST",
selectOnFocus:true,
anchor: '90%'
})

As you see, and as i need cause i make an air application, i also define a tpl. This varible looks like:


var loginComboTpl = new Ext.XTemplate(
'<tpl for="."><div class="x-combo-list-item">{#} {.} {values}</div></tpl>'
);

So my problem is that i can't get the values from my static array. The index "{#}" is right, i got 2 entry's, but i don't get the values from my array.

{.} = [object Object] ... but which one?
{values} = nothing...


so what does i have to use for that i get my values "TEST", "TEST2"? :)

greetz
Christopher

Animal
27 Mar 2010, 10:27 AM
You will still need to access field names of the fields in the Records of your Store.

When a Store is auto-created from an Array like that it creates the field names "field1" (and if you used a 2d array, "field1" and "field2")

Zerogiven
27 Mar 2010, 11:23 AM
You will still need to access field names of the fields in the Records of your Store.

When a Store is auto-created from an Array like that it creates the field names "field1" (and if you used a 2d array, "field1" and "field2")

thx a lot! is there a notice in the docs somewhere? i searched so much for something like this. If there isn't it should be ;) :D

greetz

fay
28 Mar 2010, 5:34 AM
is there a notice in the docs somewhere

It's described in the descriptions of the ComboBox (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox) displayField and valueField config options.

Zerogiven
28 Mar 2010, 11:52 AM
It's described in the descriptions of the ComboBox (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox) displayField and valueField config options.

:D, so i read about 80% from the combobox doc... poor that my solution where in the last 20% :)), however, thanks!

cheers