Sep 08, 2009, 11:36 AM
[CLOSED] Combobox not loading data
Hi,
I create a combo box and load data into its store manually, but the combo box list is empty unless before loading it was expanded at least once. I have the following code:
1. Click the 'Test' button
2. The combo input box has the correct value selected, but when expanded the drop down list is empty.
3. Close the dialog and click the 'Test' button again.
4. Expand the drop down list again - it is now populated.
If the drop down was not expanded in step 2., it would be still empty in step 4.
How to make the combo list load the values correctly for the first time?
Regards,
Tadeusz
I create a combo box and load data into its store manually, but the combo box list is empty unless before loading it was expanded at least once. I have the following code:
<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">
function onClick()
{
var data = [];
data.push({ Name: 'test1', Value: 1 });
data.push({ Name: 'test2', Value: 2 });
data.push({ Name: 'test3', Value: 3 });
store.loadData(data);
combo.setValue(1);
dialog.show();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Store ID="store" runat="server" AutoLoad="true">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="Name" Mapping="Name" />
<ext:RecordField Name="Value" Mapping="Value" Type="Int" />
<ext:RecordField Name="Order" Mapping="Order" Type="Int" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:Button runat="server" Text="Test">
<Listeners>
<Click Handler="onClick()" />
</Listeners>
</ext:Button>
<ext:Window ID="dialog" runat="server" Title="" Width="350" AutoHeight="true" Centeronload="true" Showonload="false" Modal="true" BodyStyle="padding:10px">
<Body>
<ext:FormLayout runat="server">
<ext:Anchor Horizontal="95%">
<ext:ComboBox ID="combo" runat="server" StoreID="store" Editable="false" DisplayField="Name" ValueField="Value" FieldLabel="Select" ForceSelection="true" TypeAhead="false" LazyInit="false">
</ext:ComboBox>
</ext:Anchor>
</ext:FormLayout>
</Body>
<Buttons>
<ext:Button runat="server" Text="Close">
<Listeners>
<Click Handler="#{dialog}.hide()" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>
</form>
</body>
</html>
The following steps can replicate that:1. Click the 'Test' button
2. The combo input box has the correct value selected, but when expanded the drop down list is empty.
3. Close the dialog and click the 'Test' button again.
4. Expand the drop down list again - it is now populated.
If the drop down was not expanded in step 2., it would be still empty in step 4.
How to make the combo list load the values correctly for the first time?
Regards,
Tadeusz