[CLOSED] CommandColumn and DirectEvents

  1. #1

    [CLOSED] CommandColumn and DirectEvents

    I have a GridColumn with 2 CommandColumn and a Listener:

    	....
    	....
    	<ColumnModel ID="ColumnModel1" runat="server">
    	   <Columns>
    		   ....
    		   <ext:CommandColumn Width="30">
    			   <Commands>
    				  <ext:GridCommand CommandName="Command1" />
    			   </Commands>
    		   </ext:CommandColumn>
    		   <ext:CommandColumn Width="30">
    			   <Commands>
    				  <ext:GridCommand CommandName="Command2" />
    			   </Commands>
    		   </ext:CommandColumn>
    	   </Columns>
    	</ColumnModel>
    
    	<Listeners>
    	   <Command Fn="commandHandler" />
    	</Listeners>
    	....
    	....
    This is the listener:

        <script type="text/javascript">
            var commandHandler = function (cmd, record) {
                switch (cmd) {
                    case "Command1":
                    ....
                                                                   break;
                                                                   
                    case "Command2":
                    ....
                                                                   break;
                }
            }
        </script>
    I need to replace the Listener with a DirectEvent, but how can I associate a specific DirectEvent (with a specific Url) to each CommandButton?
    There isn' an Fn attribute for Command...

    Thanks,
    Stefano
    Last edited by Vladimir; Jul 05, 2010 at 6:34 PM.
  2. #2
    CLOSED by email
  3. #3
    Would it be possible to post the solution here? I have the same question.
  4. #4
    Hello, jmcantrell!

    I don't know what solution was there.
    But if you just want to handle commands on server side I would suggest you to use direct methods.

    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.Store.Primary;
                store.DataSource = new object[] { 
                                             new object[] {"test1"},
                                             new object[] {"test2"},
                                             new object[] {"test3"}
                                    };
                store.DataBind();
            }
        }
    
        [DirectMethod]
        public void Command1_Handler()
        {
            X.Msg.Alert("Hello!", "Command1_Handler").Show();
        }
    
        [DirectMethod]
        public void Command2_Handler()
        {
            X.Msg.Alert("Hello!", "Command2_Handler").Show();
        }
    </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>
    
        <script type="text/javascript">
            var commandHandler = function(cmd, record) {
                switch (cmd) {
                    case "Command1":
                        Ext.net.DirectMethods.Command1_Handler();
                        break;
    
                    case "Command2":
                        Ext.net.DirectMethods.Command2_Handler();
                        break;
                }
            }
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                    <ext:CommandColumn Width="30">
                        <Commands>
                            <ext:GridCommand CommandName="Command1" Icon="Accept"/>
                        </Commands>
                    </ext:CommandColumn>
                    <ext:CommandColumn Width="30">
                        <Commands>
                            <ext:GridCommand CommandName="Command2" Icon="Add" />
                        </Commands>
                    </ext:CommandColumn>
                </Columns>
                <Listeners>
                </Listeners>
            </ColumnModel>
            <Listeners>
                <Command Fn="commandHandler" />
            </Listeners>
        </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. CommandColumn Sorting
    By people in forum 1.x Help
    Replies: 0
    Last Post: Apr 11, 2011, 11:49 AM
  2. [CLOSED] Inherit CommandColumn
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 02, 2011, 2:36 PM
  3. CommandColumn not align
    By walle in forum 1.x Help
    Replies: 0
    Last Post: May 13, 2010, 4:15 PM
  4. Help. regarding commandcolumn
    By ydnah2 in forum 1.x Help
    Replies: 2
    Last Post: Aug 19, 2009, 11:46 AM

Tags for this Thread

Posting Permissions