Feb 01, 2010, 5:44 AM
Strange behaviour with combo-box awith toolbar button on toolbar.
Hi,
I have toolbar with combo-box and text-fields that i hide or show according to other combo-box selection and toolbar- button that i always show.
The problem is that i decided to show the combo-box the toolbar button is disappear.
Here is a part of my code that related to this behaviour:
My .aspx file:
Thank you in advance!!!!!
Yossi.
I have toolbar with combo-box and text-fields that i hide or show according to other combo-box selection and toolbar- button that i always show.
The problem is that i decided to show the combo-box the toolbar button is disappear.
Here is a part of my code that related to this behaviour:
My .aspx file:
<ext:Panel ID="pnlSouth" Title="Edit Channels" Icon="NoteEdit" Collapsible="true" runat="server" Height="300" Collapsed="true" ButtonAlign=Left>
<TopBar>
<ext:Toolbar Hidden="true" ID="tbProperties" Height="30" runat="server">
<Items>
<ext:ToolbarTextItem ID="LblForCbox" runat="server" Text="Choose a property to edit: "></ext:ToolbarTextItem>
<ext:ComboBox ID="TypeCBox" runat="server" AllowBlank="false">
<Items>
<ext:ListItem Text="CTIDs" Value="CTID" />
<ext:ListItem Text="Vars" Value="VAR" />
<ext:ListItem Text="Countries" Value="Country" />
<ext:ListItem Text="Machines' names" Value="MachineName" />
<ext:ListItem Text="Test Groups" Value="TestGroup" />
</Items>
<SelectedItem Value="CTID" />
</ext:ComboBox>
<ext:ToolbarSeparator ID="Seperator" runat="server"></ext:ToolbarSeparator>
<ext:ToolbarButton ID="SearchButton" runat="server" Text="Go!" Icon="Magnifier" >
<AjaxEvents>
<Click OnEvent="TypeChoosed" />
</AjaxEvents>
</ext:ToolbarButton>
</Items>
</ext:Toolbar>
</TopBar>
<Body>
<ext:MultiSelect Hidden="true" StoreID="StoreMultiSelectItems" DisplayField="Text" ValueField="value" ID="ItemsList" runat="server"
Width="500" Height="240" AllowDuplicates="false" KeepSelectionOnClick="WithCtrlKey">
<TopBar>
<ext:Toolbar Hidden="true" ID="TbEditProperties" runat="server" Height="30">
<items>
<ext:toolbartextitem id="lbladditem" runat="server" ></ext:toolbartextitem>
<ext:combobox id="CboxCountries" ForceSelection="true" runat="server" Hidden="true" allowblank="false">
</ext:combobox>
<ext:combobox id="CboxTestGroups" runat="server" Hidden="true" allowblank="false">
</ext:combobox>
<ext:textfield id="itemtext" Hidden="true" runat="server" width="200"></ext:textfield>
<ext:textfield id="Ctidtext" Regex="^(C|c)(T|t)[0-9]+" RegexText="CTID is not valid!!!" Hidden="true" runat="server" width="200"></ext:textfield>
<ext:toolbarbutton id="addbutton" runat="server" text="add" icon="add" >
<ajaxevents>
<click onevent="AddItem" />
</ajaxevents>
</ext:toolbarbutton>
</items>
</ext:Toolbar>
</TopBar>
</ext:MultiSelect>
</Body>
<Buttons>
<ext:Button ID="btnSave" Disabled="true" runat="server" Text="Save" Icon="Disk">
<AjaxEvents>
<Click OnEvent="btnSave_Click">
<ExtraParams>
<ext:Parameter Name="multiSelectItems" Value="Ext.encode(#{ItemsList}.getValues(true))" Mode="Raw" />
</ExtraParams>
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnDelete" Disabled="true" runat="server"
Text="Delete" Icon="Delete" >
<AjaxEvents>
<Click OnEvent="btnDelete_Click">
<ExtraParams>
<ext:Parameter Name="SelectedItems" Value="#{ItemsList}.getIndexes('Text')" Mode="Raw" />
</ExtraParams>
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnCancel" Disabled="true" runat="server" Text="Cancel" Icon="Cancel">
<AjaxEvents>
<Click OnEvent="BtnCancel_Click"></Click>
</AjaxEvents>
</ext:Button>
</Buttons>
</ext:Panel>
my code-behind:
protected void TypeChoosed(object sender, AjaxEventArgs e)
{
//Get the type that selected
_typeSelected = (ChannelProperty) Enum.Parse(typeof (ChannelProperty), TypeCBox.SelectedItem.Value, true);
//Fill the multiselect with the items from the choosen type.
FillMultiSelct();
}
/// <summary>
/// Fill the multiselect with the items from the choosen type.
/// </summary>
private void FillMultiSelct()
{
//Clear all the previous data from the multi-select control.
StoreMultiSelectItems.RemoveAll();
//Clear the previous texts from the text-fields
itemtext.Clear();
Ctidtext.Clear();
//Show the multi-select's toolbar and the buttons
TbEditProperties.Hidden = false;
btnSave.Disabled = false;
btnDelete.Disabled = false;
btnCancel.Disabled = false;
switch (_typeSelected)
{
case ChannelProperty.CTID://CTID type has selected.
List<string> ctids = ChannelsDataSource.GetCTIDs(_channelId);
//Fill the multi-select with the CTIDs of the choosen channel
foreach (string ctid in ctids)
{
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("Value", ctid);
dictionary.Add("Text", ctid);
StoreMultiSelectItems.AddRecord(dictionary);
};
//Show the data.
CboxCountries.Hidden = true;
CboxTestGroups.Hidden = true;
ItemsList.Hidden = false;
lbladditem.Text = "Enter a CTID to add to this channel: ";
itemtext.Hidden = true;
Ctidtext.Hidden = false;
//Clear the previous text from the text-fields
itemtext.Clear();
Ctidtext.Clear();
break;
case ChannelProperty.Var://Vars type has selected.
List<string> vars = ChannelsDataSource.GetVars(_channelId);
//Fill the multi-select with the Vars of the choosen channel
foreach (string var in vars)
{
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("Value", var);
dictionary.Add("Text", var);
StoreMultiSelectItems.AddRecord(dictionary);
};
//Show the relevant controls and hide the others.
CboxCountries.Hidden = true;
CboxTestGroups.Hidden = true;
ItemsList.Hidden = false;
lbladditem.Text = "Enter a Var to add to this channel: ";
itemtext.Hidden = false;
Ctidtext.Hidden = true;
break;
case ChannelProperty.Country://Country's type has selected.
List<MultiSelectItem> channelCountries = ChannelsDataSource.GetChannelCountries(_channelId);
//Fill the multi-select with the countries of the choosen channel
foreach (MultiSelectItem country in channelCountries)
{
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("Value", country.Value);
dictionary.Add("Text", country.Text);
StoreMultiSelectItems.AddRecord(dictionary);
}
//Show the data.
itemtext.Hidden = true;
ItemsList.Hidden = false;
CboxCountries.Hidden = false;
CboxTestGroups.Hidden = true;
lbladditem.Text = "Choose a country to add to this channel: ";
Ctidtext.Hidden = true;
break;
case ChannelProperty.MachineName:
//Machine-name type has selected.
List<string> machineList = ChannelsDataSource.GetMachineNames(_channelId);
//Fill the multi-select with the machines' names of the choosen channel
foreach (string machine in machineList)
{
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("Value", machine);
dictionary.Add("Text", machine);
StoreMultiSelectItems.AddRecord(dictionary);
};
//Show the relevant controls and hide the others.
CboxCountries.Hidden = true;
CboxTestGroups.Hidden = true;
ItemsList.Hidden = false;
lbladditem.Text = "Enter a Machine's name to add to this channel: ";
itemtext.Hidden = false;
Ctidtext.Hidden = true;
break;
case ChannelProperty.TestGroup:
//Test-group type has selected
List<MultiSelectItem> channelTestGroups = ChannelsDataSource.GetChannelTestGrops(_channelId);
//Fill the multi-select with the countries of the choosen channel
foreach (MultiSelectItem testGroup in channelTestGroups)
{
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("Value", testGroup.Value);
dictionary.Add("Text", testGroup.Text);
StoreMultiSelectItems.AddRecord(dictionary);
}
//Show the data.
itemtext.Hidden = true;
ItemsList.Hidden = false;
CboxCountries.Hidden = true;
CboxTestGroups.Hidden = false;
lbladditem.Text = "Choose a test-group to add to this channel: ";
Ctidtext.Hidden = true;
break;
}
}
Thank you in advance!!!!!
Yossi.