2 different command columns in gridpanel

  1. #1

    2 different command columns in gridpanel

    Hello. I've been trying to put two different command columns in a gridpanel. The two buttons should call a different method, but they will call BOTH methods. Here's the code:
    <ext:CommandColumn Width="75" Locked="true">
                            <Commands>
                                <ext:GridCommand Icon="Add" CommandName="ProdIn" Text="In"></ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
    
                        <ext:CommandColumn Width="75" Locked="true">
                            <Commands>
                                <ext:GridCommand Icon="Delete" CommandName="ProdOut" Text="Out"></ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                    <Command OnEvent="ProdIn" Failure="Ext.MessageBox.alert('Load failed', 'Error during ajax event!');">
                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{GridPanel1}.body}" />
                        <ExtraParams>
                            <ext:Parameter Name="idProd" Value="record.data.idProd" Mode="Raw"></ext:Parameter>
                            <ext:Parameter Name="quantity" Value="record.data.quantity" Mode="Raw"></ext:Parameter>
                        </ExtraParams>
                    </Command>
    
                    <Command OnEvent="ProdOut" Failure="Ext.MessageBox.alert('Load failed', 'Error during ajax event!');">
                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{GridPanel1}.body}" />
                        <ExtraParams>
                            <ext:Parameter Name="idProd" Value="record.data.idProd" Mode="Raw"></ext:Parameter>
                            <ext:Parameter Name="quantity" Value="record.data.quantity" Mode="Raw"></ext:Parameter>
                        </ExtraParams>
                    </Command>
    Methods (top of page):

        protected void ProdIn(object sender, DirectEventArgs e) 
        {
            string id = e.ExtraParams["idProd"];
            string existencia = e.ExtraParams["quantity"];
            this.popupIn.ShowIn(idProd, quantity);
        }
    
        protected void ProdOut(object sender, DirectEventArgs e) 
        {
            string id = e.ExtraParams["idProd"];
            string existencia = e.ExtraParams["quantity"];
            this.popupOut.ShowOut(idProd, quantity);
        }
    This works fine with one command column, but calls the two methods when any of the two buttons are clicked.
    They are DirectEvents.

    Help please? :)

    Thanks in advance.
  2. #2
    Both columns fires "command" event, only one event handler can be declared
    Pass command name as extra parameter to distinguish what exactly command was clicked
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Well, I couldn't figure this out. So I made another functionality that doesn't require two columns. And it actually works better with my design.
    Thanks for the very fast answer anyway.

Similar Threads

  1. Help GridPanel Command Confirmation
    By libra163 in forum 1.x Help
    Replies: 2
    Last Post: Oct 25, 2011, 7:40 AM
  2. Replies: 1
    Last Post: Sep 15, 2011, 2:54 PM
  3. Add command column in gridpanel
    By tmducit in forum 1.x Help
    Replies: 1
    Last Post: May 27, 2011, 12:27 PM
  4. Icons not showing in GridPanel Command Columns
    By Groovepoets in forum 1.x Help
    Replies: 3
    Last Post: Oct 20, 2010, 4:52 PM
  5. GridPanel Command
    By Timothy in forum 1.x Premium Help
    Replies: 2
    Last Post: Mar 05, 2009, 3:55 PM

Tags for this Thread

Posting Permissions