Mar 05, 2010, 10:42 AM
[CLOSED] Icon ComboBox does not show the icon when the item slected value is setted by code?
Hi,
I am using the Icon comboBox. When I run the application it looks fine, every icon is with its item and when select an item it shows the selected item with the icon.
The problem that I found is when a set a default value to the item selected when the page is loaded. It shows just the text but not the Icon.
I am using the Icon comboBox. When I run the application it looks fine, every icon is with its item and when select an item it shows the selected item with the icon.
The problem that I found is when a set a default value to the item selected when the page is loaded. It shows just the text but not the Icon.
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
createLanguagesDataSource();
this.ComboBoxLanguages.SelectedItem.Value = "en-US";
}
}
protected void createLanguagesDataSource()
{
this.StoreLanguages.DataSource = new object[]
{
new object[] { ResourceManager.GetIconClassName(Icon.FlagUs), "English", "en-US"},
new object[] { ResourceManager.GetIconClassName(Icon.FlagEs), "Spanish", "es-CO"}
};
this.StoreLanguages.DataBind();
ResourceManager1.RegisterIcon(Icon.FlagUs);
ResourceManager1.RegisterIcon(Icon.FlagEs);
}
<ext:Store ID="StoreLanguages" runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="iconCls" />
<ext:RecordField Name="name" />
<ext:RecordField Name="culture" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:ComboBox
ID="ComboBoxLanguages"
runat="server"
StoreID="StoreLanguages"
Width="100px"
Editable="false"
DisplayField="name"
ValueField="culture"
Mode="Local"
TriggerAction="All"
EmptyText="Language">
<Template ID="Template1" runat="server">
<Html>
<tpl for=".">
<div class="x-combo-list-item icon-combo-item {iconCls}">
{name}
</tpl>
</Html>
</Template>
<Listeners>
<Select Handler="this.setIconCls(record.get('iconCls'));" />
</Listeners>
<DirectEvents>
<Select OnEvent="ComboBoxLanguagesSelect"/>
</DirectEvents>
</ext:ComboBox>