PDA

View Full Version : [CLOSED] linked ComboBox



tactime10
Sep 20, 2012, 5:29 PM
Hi,

I put in my page two combobox and I want that filter one combobox if I select one item into another combobox, but my code does not work.
I attached an example below



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

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">

protected void ReloadComboBoxAction(object sender, DirectEventArgs e) {
PopulateCombo();
}

protected void PopulateCombo() {
IList list = null;
if (comboBoxWorkCenterAction.SelectedItem == null || comboBoxWorkCenterAction.SelectedItem.Index == 0) {

list = CreateItemsComboBoxOperation();
} else {

list = CreateItemsComboBoxOperation1();
}
for (int i = 0;i < list.Count;i++) {
string operationIth = (string)list[i];
comboBoxOperationAction.Items.Add(new Ext.Net.ListItem(operationIth,i.ToString()));
}

comboBoxOperationAction.DataBind();
}

public IList CreateItemsComboBoxOperation() {
IList listaOperation = new ArrayList();

string element1 = "operation 01";
string element2 = "operation 02";
string element3 = "operation 03";


listaOperation.Add(element1);
listaOperation.Add(element2);
listaOperation.Add(element3);

return listaOperation;
}

public IList CreateItemsComboBoxOperation1() {
IList listaOperation = new ArrayList();

string element1 = "operation 01";
string element3 = "operation 03";

listaOperation.Add(element1);
listaOperation.Add(element3);

return listaOperation;
}

public void Page_Load() {
PopulateCombo();
}

</script>

<!DOCTYPE html>

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

<h1>Example</h1>

<ext:Panel runat="server" Layout="HBoxLayout" Border="false" AutoHeight="true" Header="false">
<Defaults>
<ext:Parameter Name="margins" Value="5 5 0 5" Mode="Value" />
</Defaults>
<LayoutConfig>
<ext:HBoxLayoutConfig />
</LayoutConfig>
<Items>
<ext:ComboBox ID="comboBoxWorkCenterAction" runat="server" EmptyText="-- All --">
<Items>
<ext:ListItem Text="WorkCenter1" />
<ext:ListItem Text="WorkCenter2" />
<ext:ListItem Text="WorkCenter3" />
</Items>
<DirectEvents>
<Select OnEvent="ReloadComboBoxAction">
<EventMask ShowMask="true" MinDelay="200" />
</Select>
</DirectEvents>
</ext:ComboBox>
<ext:ComboBox ID="comboBoxOperationAction" runat="server" EmptyText="-- All --">
</ext:ComboBox>
</Items>
</ext:Panel>
</form>
</body>
</html>


Can you help me for this issue?
Thank you so much.

Daniil
Sep 20, 2012, 7:16 PM
Hi,

Please wrap the Page_Load code in:

public void Page_Load() {
if (!X.IsAjaxRequest)
{
PopulateCombo();
}
}
and replace

comboBoxOperationAction.DataBind();
with

comboBoxOperationAction.GetStore().DataBind();

tactime10
Sep 21, 2012, 9:02 AM
Hi,

ok now it works.

Thanks.

Why I don't receive an email when you reply to the thread?

Daniil
Sep 21, 2012, 12:05 PM
Why I don't receive an email when you reply to the thread?

I think it was because of the forums didn't work well yesterday.

But please check your Notification settings: Settings (at the top) => General Settings (at the left) => Messaging & Notification.

There must be "Instantly, using email".

tactime10
Sep 21, 2012, 1:20 PM
The settings was correct. I think the forums didn't work well yesterday as you said me because now it works.
Thanks

Daniil
Sep 21, 2012, 1:23 PM
Okay, thank you for confirming!