PDA

View Full Version : [CLOSED] Select Combobox-Item after Store reload



blueworld
Nov 13, 2013, 4:58 PM
Hi,

I have a Combobox that gets items in a specific order after store reload.
After each store reload, I would like to select the first item.

Why does this code not work? The combobox items are refreshed but nothing is selected
I am refreshing the combobox with a button click, on page load its empty.



<Click Handler="#{StoreMatching}.reload();" />




<ext:ComboBox ID="ComboBoxMatchingVehicles"
runat="server"
Editable="false"
DisplayField="Vname"
ValueField="Vid"
QueryMode="Local"
ForceSelection="true"
TriggerAction="All"
EmptyText="Keine Fahrzeuge vorhanden">
<Store>
<ext:Store ID="StoreMatching" runat="server">
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="Vid" />
<ext:ModelField Name="Vname" />
<ext:ModelField Name="Percentage" />
</Fields>

</ext:Model>

</Model>
<Parameters>
<ext:StoreParameter Name="currentCategory" Value="#{hiddenCategoryName}.getValue()" Mode="Raw" />
<ext:StoreParameter Name="Date" Value="#{DateField}.getValue()" Mode="Raw" />
</Parameters>
</ext:Store>
</Store>
<ListConfig>
<ItemTpl ID="ItemTpl1" runat="server">
<Html>
<div class="list-item">
<h3>{Vname}</h3>
{Percentage}
</div>
</Html>
</ItemTpl>
</ListConfig>
</ext:ComboBox>





Protected Sub ComboBoxMatchingVehicles_Load(ByVal sender As Object, ByVal e As Ext.Net.StoreReadDataEventArgs) Handles StoreMatching.ReadData
.
.
.

Me.ComboBoxMatchingVehicles.GetStore().DataSource = md
Me.ComboBoxMatchingVehicles.GetStore().DataBind()
Me.ComboBoxMatchingVehicles.Select(0)
End Sub


Thank you

Baidaly
Nov 13, 2013, 5:56 PM
Hello!

Try to use UpdateSelectedItems:


Me.ComboBoxMatchingVehicles.UpdateSelectedItems()

Daniil
Nov 14, 2013, 4:53 AM
Hi,

It appears to be working in this example.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.DataBind();
}
}

protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
{
this.DataBind();
this.ComboBox1.Select(0);
}

private void DataBind()
{
Store store = this.ComboBox1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "Item 1" },
new object[] { "2", "Item 2" },
new object[] { "3", "Item 3" }
};
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Reload" Handler="App.ComboBox1.store.reload();" />

<ext:ComboBox
ID="ComboBox1"
runat="server"
DisplayField="text"
ValueField="value">
<Store>
<ext:Store runat="server" OnReadData="Store_ReadData">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:ComboBox>
</form>
</body>
</html>

blueworld
Nov 14, 2013, 4:29 PM
Hi Daniil and Baidaly,

this morning it was working as well, without changes to the code. Maybe this was caused by a bad connection or whatever.