Nov 08, 2012, 9:48 AM
How to fire Direct event on the dynamic CommandColumn?
hey
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic"%>
<%@ Import Namespace="ListView=Ext.Net.ListView"%>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string id = Convert.ToString(1);
Store store = new Store { ID = "StoreRow_" + id };
Model model = new Model();
DataTable dtTrend = new DataTable();
dtTrend.Columns.Add("Name", typeof(string));
dtTrend.Columns.Add("Data", typeof(int));
dtTrend.Rows.Add("Day 1 ", 0);
dtTrend.Rows.Add("Day 2 ", 0);
dtTrend.Rows.Add("Day 3 ", 0);
dtTrend.Rows.Add("Day 4 ", 0);
dtTrend.Rows.Add("Day 5", 0);
dtTrend.Rows.Add("Day 6", 0);
foreach (DataColumn dc in dtTrend.Columns)
{
ModelField modelField = new ModelField { Name = dc.ColumnName, Mapping = dc.ColumnName, Type = ModelFieldType.String };
model.Fields.Add(modelField);
}
store.Model.Add(model);
store.DataSource = dtTrend;
GrdSessions.Store.Add(store);
foreach (DataColumn dc in dtTrend.Columns)
{
GrdSessions.ColumnModel.Columns.Add(new Column { Text = dc.ColumnName.Replace('_', ' '), DataIndex = dc.ColumnName, Width = 100 });
}
CommandColumn commandColumn = new CommandColumn();
commandColumn.ID = "colAction" + System.Guid.NewGuid();
commandColumn.Flex = 1;
commandColumn.Text = "View";
commandColumn.DataIndex = "Id";
commandColumn.Commands.Add(new GridCommand { Icon = Ext.Net.Icon.Note, CommandName = "View", Text = "View" });
commandColumn.DirectEvents.Command.Event += GrdInbox_Command;
commandColumn.DirectEvents.Command.ExtraParams.Add(new Parameter { Name = "Id", Value = "record.data.Id" });
commandColumn.DirectEvents.Command.ExtraParams.Add(new Parameter { Name = "command", Value = "command" });
GrdSessions.ColumnModel.Columns.Add(commandColumn);
GrdSessions.Render(pnlSessionGeneric, 0, RenderMode.InsertTo);
}
protected void GrdInbox_Command(object sender, DirectEventArgs e)
{
string commandName = e.ExtraParams["command"];
long Id = Convert.ToInt64(e.ExtraParams["Id"]);
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Panel ID="pnlSessionGeneric" runat="server" AutoScroll="true" Border="false"
autowidth="true" Layout="FitLayout" Header="false" Height="230">
<Content>
<ext:GridPanel ID="GrdSessions" runat="server" Layout="AnchorLayout" AnchorHorizontal="100%"
Padding="5" Title="Session List" AnimCollapse="true" AutoScroll="true" Height="200">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" TrackOver="true" />
</View>
</ext:GridPanel>
</Content>
</ext:Panel>
</form>
</body>
</html>
can you help me where and what i am missing