PDA

View Full Version : [CLOSED] Populate a ComboBox with JSON



Peter.Treier
Mar 06, 2014, 12:49 PM
Hi all

I need to Fill a ComboBox with this Data :


[
{
"Key": "Test Source",
"Value": "Test Source"
},
{
"Key": "Test Source 2",
"Value": "Test Source 2"
},
{
"Key": "Test Source 3",
"Value": "Test Source 3"
}
]

The ComboBox is defined like this :



<ext:ComboBox runat="server" ID="cboEntrySource" FieldLabel="SelectSource" DisplayField="Value" ValueField="Key" LabelAlign="Top" TypeAhead="true" PaddingSpec="10 0 0 0">
<Store>
<ext:Store ID="storeEntrySource" runat="server" AutoLoad="true">
<Model>
<ext:Model ID="modelEntrySource" runat="server" IDProperty="Key">
<Fields>
<ext:ModelField Name="Value" />
<ext:ModelField Name="Key" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:JsonReader />
</Reader>
</ext:Store>
</Store>
</ext:ComboBox>


I try to Bind the Data like this :


var cbo = Ext.getCmp('ContentPanel_cboEntrySource');
if (cbo != null) {
var store = cbo.getStore();
store.loadRawData(ret);
}

The Store seems to receive the Data, but the Combo doesn't show them ?

Any Hints ?

Thanks
Peter

Daniil
Mar 06, 2014, 3:28 PM
Hi Peter,

Please set up the following for the ComboBox.

QueryMode="Local"

Peter.Treier
Mar 07, 2014, 6:46 AM
Ha ! Classic :-)