Oct 26, 2015, 9:11 PM
[CLOSED] How to pre select a value in ComboBox inside ComponentColumn
Hello,
I am trying to pre-select a value in the cmbAdjustmentTypes combobox during Page_Load but it is not working. For example, Employee 1 is suppose to have AdjustmentType 1 pre selected but it is not.
Please see screenshot for reference.
Below is my code:
I am trying to pre-select a value in the cmbAdjustmentTypes combobox during Page_Load but it is not working. For example, Employee 1 is suppose to have AdjustmentType 1 pre selected but it is not.
Please see screenshot for reference.
Below is my code:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Newtonsoft.Json" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest || !IsPostBack)
{
this.Store1.DataSource = new object[]
{
new object[] { "Employee 1", 1,3 },
new object[] { "Employee 2", 2,3 },
new object[] { "Employee 3", 2,3 },
new object[] { "Employee 4", 2,3},
new object[] { "Employee 5", 2,3 },
new object[] { "Employee 6",8,3},
new object[] { "Employee 7", 8,3 },
new object[] { "Employee 8", 8,3},
new object[] { "Employee 9", 9,3}
};
this.Store1.DataBind();
stAdjustmentTypes.DataSource = GetAdjustmentTypes();
stAdjustmentTypes.DataBind();
}
}
public List<AdjustmentType> GetAdjustmentTypes()
{
List<AdjustmentType> adj = new List<AdjustmentType>(3);
for (int j = 0; j < 10; j++)
{
adj.Add(new AdjustmentType("Adjustment Type " + j, j));
}
return adj;
}
public class AdjustmentType
{
public AdjustmentType(string name, int adjustmentTypeID)
{
AdjustmentName = name;
AdjustmentTypeID = adjustmentTypeID;
}
public string AdjustmentName { get; set; }
public int AdjustmentTypeID { get; set; }
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>ComponentColumn Over Editor - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
<style>
.x-over-editor-grid tr.x-grid-row
{
height: 22px;
}
</style>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<h1>
ComponentColumn multi controls</h1>
<ext:GridPanel ID="GridPanel1" runat="server" Title="Setup Adjustments" Width="1200"
Height="300">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="EmployeeName" Type="String" />
<ext:ModelField Name="AdjustmentTypeID" Type="Int" />
<ext:ModelField Name="RouteID" Type="Int" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="EmployeeName" Text="Adjustment Type">
</ext:Column>
<ext:ComponentColumn ID="ComponentColumn2" runat="server" Editor="true" Text="Adjustment"
Width="600">
<Component>
<ext:Container runat="server">
<Items>
<ext:ComboBox ID="cmbAdjustmentTypes" runat="server" DataIndex="AdjustmentTypeID" ValueField="AdjustmentTypeID" DisplayField="AdjustmentName" EmptyText="Select Adjustment">
<Store>
<ext:Store ID="stAdjustmentTypes" runat="server" IsPagingStore="false" AutoLoad="false">
<Model>
<ext:Model ID="mdAjustmentType" runat="server">
<Fields>
<ext:ModelField Name="AjustmentTypeID" />
<ext:ModelField Name="AdjustmentName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
<ext:ComboBox ID="ComboBox2" runat="server" DataIndex="RouteID" EmptyText="Select Route">
<Items>
<ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
<ext:ListItem Text="Item 2" Value="2" Mode="Raw" />
<ext:ListItem Text="Item 3" Value="3" Mode="Raw" />
<ext:ListItem Text="Item 4" Value="4" Mode="Raw" />
<ext:ListItem Text="Item 5" Value="5" Mode="Raw" />
<ext:ListItem Text="Item 6" Value="6" Mode="Raw" />
<ext:ListItem Text="Item 7" Value="7" Mode="Raw" />
<ext:ListItem Text="Item 8" Value="8" Mode="Raw" />
<ext:ListItem Text="Item 9" Value="9" Mode="Raw" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
</Component>
</ext:ComponentColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>
Last edited by Daniil; Oct 29, 2015 at 7:09 AM.
Reason: [CLOSED]