PDA

View Full Version : [CLOSED] How can I make ImageCommandColumn pass a Parameter



tobros
Jun 09, 2013, 10:32 AM
this is a gridpanel ,in the gridpanel,have a ImageCommandColumn ,I want to pass a parameter which name is 'parentcode',
this is my code.

<ext:ImageCommandColumn runat="Server">
<Commands>
<ext:ImageCommand runat="Server" CommandName="Add" Icon="TableEdit" Text="Add"></ext:ImageCommand>
</Commands>

<DirectEvents>

<Command OnEvent="OnAdd_Click">

<ExtraParams>
<ext:Parameter runat="Server" Name="parentcode" Value="record.data.ParentCode" Mode="Raw"></ext:Parameter>
</ExtraParams>
</Command>

</DirectEvents>
</ext:ImageCommandColumn>

if (Request.Params["parentcode"]==null)
{
ParentCode.Text="顶级科目";
}
but I can't get the parameter

Daniil
Jun 10, 2013, 6:31 AM
Hi @tobros,

Please access the parameter via

e.ExtraParams["parentcode"]
instead of

Request.Params["parentcode"]

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" }
};
}
}

protected void OnAdd_Click(object sender, DirectEventArgs e)
{
X.Msg.Alert("OnAdd_Click", e.ExtraParams["test1"]).Show();
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test1" DataIndex="test1" />
<ext:Column runat="server" Text="Test2" DataIndex="test2" />
<ext:Column runat="server" Text="Test3" DataIndex="test3" />
<ext:ImageCommandColumn runat="server">
<Commands>
<ext:ImageCommand
runat="Server"
CommandName="Add"
Icon="TableEdit"
Text="Add" />
</Commands>

<DirectEvents>
<Command OnEvent="OnAdd_Click">
<ExtraParams>
<ext:Parameter
Name="test1"
Value="record.data.test1"
Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>