Jan 11, 2010, 12:08 PM
[CLOSED] GridPanel Dynamic Editor Fields
Hi folks,
I have a GridPanel in which I would like to render a different Editor Control based on my custom type.
The example below is based on yours Data Prepare example.
The custom type is a column within the same data.
I'd like to give the user the abilitity to use a datefield is the my custom type is "date" or a textfield if my custom type is "text". I could not figure out how to do this.
I noticed the editor accepts only one child control. However I also noticed the Editor accept Coolite MultiField type and someone already tackle a similar question here (if it is possible to use MultiField in GridPanel? Didn't work for me either). I really don't know. Maybe the solution is use MultiField, maybe there is another solution, I am just guessing.
At the moment I use an extended version of the asp:GridView with edit option. Similar to Data Prepare, on DataBound I render the right control (combobox, textbox), based on my criteria.
As an additional complexity, my "Information" is recursive. If the information has parent data, I'd like to ignore the Description field and display a combobox with the list of child name/id on the parent.
It is a level of complexity that I could not achieve so far, and I hope to find a solution as I am converting all my screens to Coolite-Only controls. I will consider any other solution. It is very important at this stage.
Thank you.
Leo.
I have a GridPanel in which I would like to render a different Editor Control based on my custom type.
The example below is based on yours Data Prepare example.
The custom type is a column within the same data.
I'd like to give the user the abilitity to use a datefield is the my custom type is "date" or a textfield if my custom type is "text". I could not figure out how to do this.
I noticed the editor accepts only one child control. However I also noticed the Editor accept Coolite MultiField type and someone already tackle a similar question here (if it is possible to use MultiField in GridPanel? Didn't work for me either). I really don't know. Maybe the solution is use MultiField, maybe there is another solution, I am just guessing.
At the moment I use an extended version of the asp:GridView with edit option. Similar to Data Prepare, on DataBound I render the right control (combobox, textbox), based on my criteria.
As an additional complexity, my "Information" is recursive. If the information has parent data, I'd like to ignore the Description field and display a combobox with the list of child name/id on the parent.
It is a level of complexity that I could not achieve so far, and I hope to find a solution as I am converting all my screens to Coolite-Only controls. I will consider any other solution. It is very important at this stage.
Thank you.
Leo.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ 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)
{
List<Information> list = new List<Information>(5);
for (int i = 1; i <= 8; i++)
{
Information info = new Information
{
ID = i,
Name = ("Info Name" + i),
Description = "Description" + i,
InfoType = "Type" + i,
Valid = Convert.ToBoolean(i % 2)
};
if (info.InfoType.Equals("Type3") || info.InfoType.Equals("Type5"))
info.Description = DateTime.Today.ToShortDateString();
if (i > 5)
info.ParentInfo = list[1];
else
list.Add(info);
}
Store1.DataSource = list;
Store1.DataBind();
}
public class Information
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string InfoType { get; set; }
public bool Valid { get; set; }
public Information ParentInfo { get; set; }
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Based on Coolite Toolkit Example - Data Prepare</title>
<script type="text/javascript">
function prepare(value, rec) {
rec.Name = value.Name;
rec.Description = value.Description;
rec.InfoType = value.InfoType;
rec.Valid = value.Valid;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Store runat="server" ID="Store1" AutoLoad="true" SerializationMode="Complex">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="ID" Type="Int" />
<ext:RecordField Name="Name" />
<ext:RecordField Name="Description" />
<ext:RecordField Name="Valid" />
<ext:RecordField Name="InfoType" />
<ext:RecordField Name="ParentInfo">
<%--<Convert Fn="prepare" />--%>
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Customers"
ClicksToEdit="1"
Height="300"
StoreID="Store1">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="ID" DataIndex="ID" />
<ext:Column Header="Name" DataIndex="Name" />
<ext:Column Header="Description" DataIndex="Description">
<Editor>
<ext:TextField ID="TextField1" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
<ext:CheckColumn Header="Active" DataIndex="Valid" />
<ext:Column Header="InfoType" DataIndex="InfoType" />
</Columns>
</ColumnModel>
<LoadMask ShowMask="true" />
</ext:GridPanel>
</form>
</body>
</html>