Dec 05, 2019, 5:41 PM
Databound Combobox Trigger from DirectEvent not showing items
I found the following thread which is similar HERE and tried a few suggestions from there but still am not getting any data showing up.
I am new to Ext.net the company I am working for is using it and yes its still version 2, but here is what I am trying to accomplish:
Here is how I have setup the items in code:
I am new to Ext.net the company I am working for is using it and yes its still version 2, but here is what I am trying to accomplish:
- Select item from combo box
- On the select event grab the relevant data based on the selected value
- use selected data in separate combo box
Here is how I have setup the items in code:
// view
// data store
<ext:Store runat="server" ID="uxDistrictsStore">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="NAME" />
<ext:ModelField Name="ID" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy />
</Proxy>
</ext:Store>
// 1st selection combo box
<ext:ComboBox runat="server" ID="uxBusinessUnits" LabelWidth="145" InputWidth="250"
FieldLabel="Business Unit" DisplayField="NAME" ValueField="ID" AllowBlank="false"
StoreID="uxBusinessUnitsStore" ForceSelection="true" QueryMode="local" TypeAhead="true">
<DirectEvents>
<Select OnEvent="deBusinessUnitsChanged"></Select>
</DirectEvents>
<Plugins>
<ext:ClearButton runat="server" />
</Plugins>
</ext:ComboBox>
// 2nd combo box
<ext:ComboBox runat="server" ID="uxDistricts" LabelWidth="145" InputWidth="250"
FieldLabel="District" DisplayField="NAME" ValueField="ID" AllowBlank="false"
StoreID="uxDistrictsStore" ForceSelection="true" QueryMode="local" TypeAhead="true">
<Plugins>
<ext:ClearButton runat="server" />
</Plugins>
</ext:ComboBox>
// code behind - I have verified the data source is populated before being bound and there are no errors during binding
[DirectMethod]
protected void deBusinessUnitsChanged(object sender, EventArgs e)
{
try
{
if (int.TryParse(uxBusinessUnits.SelectedItem.Value, out int currentBusinessUnitID))
{
using (Entities _context = new Entities())
{
uxDistrictsStore.DataSource = _context.LEADS_DISTRCITS.Where(w => w.BUSINESS_UNIT_ID == currentBusinessUnitID).OrderByDescending(o => o.ID).ToList();
uxDistrictsStore.DataBind();
}
}
else
{
X.Msg.Alert("Error", "Unable to load Districts data. Please try again later. If the issue persists, please contact IT.").Show();
}
}
catch (Exception)
{
X.Msg.Alert("Error", "Unable to load Districts data. Please try again later. If the issue persists, please contact IT.").Show();
}
}