Oct 11, 2012, 1:41 PM
[CLOSED] Problem to list through item combo from code behind
Hello
Basicaly I want to do that:
But items.count=0, so how to list all items in the combo?
I try to look at store level too, but found nothing until now.
Basicaly I want to do that:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var store = this.ComboBox1.GetStore();
store.DataSource = new object[]
{
new object[] { ResourceManager.GetIconClassName(Icon.FlagFr), "France"},
new object[] { ResourceManager.GetIconClassName(Icon.FlagCa), "Canada"},
new object[] { ResourceManager.GetIconClassName(Icon.FlagDe), "Germany"},
new object[] { ResourceManager.GetIconClassName(Icon.FlagUs), "United States"},
new object[] { ResourceManager.GetIconClassName(Icon.FlagIt), "Italy"}
};
store.DataBind();
this.ResourceManager1.RegisterIcon(Icon.FlagFr);
this.ResourceManager1.RegisterIcon(Icon.FlagCa);
this.ResourceManager1.RegisterIcon(Icon.FlagDe);
this.ResourceManager1.RegisterIcon(Icon.FlagUs);
this.ResourceManager1.RegisterIcon(Icon.FlagIt);
for (int i = 0; i < this.ComboBox1.Items.Count-1; i++)
{
//do something
}
}
</script>
<html>
<head id="Head1" runat="server">
<title>IconCombo - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.icon-combo-item {
background-repeat : no-repeat !important;
background-position : 3px 50% !important;
padding-left : 24px !important;
}
</style>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<h1>Render an Icon in ComboBox data items</h1>
<ext:ComboBox
ID="ComboBox1"
runat="server"
Width="250"
Editable="false"
DisplayField="name"
ValueField="name"
QueryMode="Local"
TriggerAction="All"
EmptyText="Select a country...">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="iconCls" />
<ext:ModelField Name="name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ListConfig>
<ItemTpl ID="ItemTpl1" runat="server">
<Html>
<div class="icon-combo-item {iconCls}">
{name}
</div>
</Html>
</ItemTpl>
</ListConfig>
<Listeners>
<Change Handler="if(this.valueModels.length>0){this.setIconCls(this.valueModels[0].get('iconCls'));}" />
</Listeners>
</ext:ComboBox>
</form>
</body>
</html>
(see last lines of the Page_Load function)But items.count=0, so how to list all items in the combo?
I try to look at store level too, but found nothing until now.
Last edited by Daniil; Oct 15, 2012 at 5:58 PM.
Reason: [CLOSED]