Feb 15, 2009, 10:38 PM
Populating ComboBox from Store on page load
Hi all,
This seems trivial, but I can't seem to make it work. Can you guys help me? On page load, I want a ComboBox to load item from a Store. This is the code:
Thanks.
This seems trivial, but I can't seem to make it work. Can you guys help me? On page load, I want a ComboBox to load item from a Store. This is the code:
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server"></ext:ScriptManager>
<ext:Store ID="Store1" runat="server" AutoLoad="true">
<Proxy>
<ext:ScriptTagProxy Url="http://localhost:2666/Api/ListPerson"></ext:ScriptTagProxy>
</Proxy>
<Reader>
<ext:JsonReader Root="root">
<Fields>
<ext:RecordField Name="id" Mapping="Id" Type="Auto"></ext:RecordField>
<ext:RecordField Name="name" Mapping="Name"></ext:RecordField>
<ext:RecordField Name="age" Mapping="Age" Type="Int"></ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:ComboBox runat="server"
ID="ComboBox1"
StoreID="Store1"
ValueField="Id"
DisplayField="Name"
LoadingText="Loading..."
Editable="false"
Mode="Local"
TriggerAction="All"
EmptyText="Empty"
ValueNotFoundText="Not found">
</ext:ComboBox>
</form>
The web service is being fetched properly since I can see the response using FireBug. Sample of the web service result:{
root: [
{ Id: '1', Name: 'Person1', Age: 1},
{ Id: '2', Name: 'Person2', Age: 2},
{ Id: '3', Name: 'Person3', Age: 3},
{ Id: '4', Name: 'Person4', Age: 4}
]
}
But the items never appear in the ComboBox, it shows "Empty" (the EmptyText) instead. Anything that I missed? Thanks.