Jan 07, 2009, 1:02 AM
Combobox Renderer in Gridpanel bug
Hi there,
My goal is to have a GridPanel with a column that will be a combobox, however I want this combobox to display a text name but store a unique identifier behind the scenes.
I have a working example, but have found that a specific sequence of user actions is causing the unique identifier to display instead of the text.
I have attached the sequence of events in the attached JPG (SequenceScreenShot.jpg).
Following is the code to reproduce my problem.
Thanks for all the work and support you guys are doing on this!
<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Store1.DataSource = new object[]
{
new object[] { "AL", "1",},
new object[] { "AK", "2",},
new object[] { "AZ", "3",},
new object[] { "AR", "4",},
new object[] { "CA", "5",}
};
this.Store1.DataBind();
this.Store2.DataSource = new object[]
{
new object[] { "John", "1"},
new object[] { "James", "2"},
new object[] { "Jerry", "3"},
new object[] { "Horatio", "4"},
new object[] { "Bob", "5"} ,
new object[] { "Larry", "5"}
};
this.Store2.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ComboBox Example</title>
</head>
<script>
function RenderStateName(value) {
if(value)
return Store1.getById(value).data.state;
}
</script>
<body style="margin:10px;">
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Store ID="Store1" runat="server">
<Reader>
<ext:ArrayReader ReaderID="id">
<Fields>
<ext:RecordField Name="state" />
<ext:RecordField Name="id" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:Store ID="Store2" runat="server">
<Reader>
<ext:ArrayReader ReaderID="stateId">
<Fields>
<ext:RecordField Name="name" />
<ext:RecordField Name="stateId" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store2" Height="300">
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>
<ext:Column DataIndex="name" Header="Name" />
<ext:Column ColumnID="state" DataIndex="stateId" Header="State" Width="200">
<Renderer Fn="RenderStateName" />
<Editor>
<ext:ComboBox ID="cb1" runat="server" StoreID="Store1"
DisplayField="state" ValueField="id"
AllowBlank="false" Mode="local">
</ext:ComboBox>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>