[CLOSED] How can I make ImageCommandColumn pass a Parameter

  1. #1

    [CLOSED] How can I make ImageCommandColumn pass a Parameter

    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
    Last edited by Daniil; Jun 18, 2013 at 4:53 AM. Reason: [CLOSED]
  2. #2
    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>

Similar Threads

  1. [CLOSED] How to pass parameter when using HttpWriteProxy
    By Daly_AF in forum 1.x Premium Help
    Replies: 2
    Last Post: Apr 16, 2012, 10:46 PM
  2. Pass Parameter to store at runtime
    By Vaishali in forum 1.x Help
    Replies: 0
    Last Post: Feb 07, 2012, 7:58 AM
  3. pass parameter by selected row in grid panel
    By vahid.ch in forum 1.x Help
    Replies: 0
    Last Post: Dec 19, 2011, 12:05 PM
  4. How to pass object as a parameter?
    By diegovbs in forum 1.x Help
    Replies: 1
    Last Post: Jan 04, 2011, 6:53 PM
  5. Replies: 18
    Last Post: Mar 17, 2010, 3:40 PM

Posting Permissions